I have:
class C:
aaa=2
class B:
def __init__ (self,name):
self.name
self.value
How can i define class C
so when i dynamically set attribute to instance it make that attribute instance of class B
. And attribute name of class B
have to have attribute name
equal string of name of that new attribute in class C
and attribute value
of B
instance have to have value what set in new attribute in instance of class C
.
Have to give me that result:
>> c=C()
>> c.whatever= 'strinstrinsstring'
>> isinstance(c.whatever,B)
True
>> c.whatever.value
'strinstrinsstring'
>>c.whatever.name
'whatever'