Class constructor parameter: dictionary : Class Dict « Class « Python






Class constructor parameter: dictionary

Class constructor parameter: dictionary

class Bunch(object):
    def __init__(self, **fields): 
        self.__dict__ = fields
        
p = Bunch(x=2.3, y=4.5)
print p                     

print p.__dict__
           
       








Related examples in the same category

1.Add a class member variable on the flyAdd a class member variable on the fly