passing variables as object attributes
nitinpawar432 at gmail.com
Mon Aug 16 15:53:39 CEST 2010
you would need to define a class first with its attiributes and then you may
want to initiate the variables by calling the class initilializer
On Mon, Aug 16, 2010 at 7:10 PM, Vikas Mahajan <vikas.mahajan12 at gmail.com>wrote:
> Hello to all
> I am new to python. I am facing problem to use variables as object
> attributes. I have to use loop and dynamically add attributes to a
> object and for this purpose I have to use variables with object names.
> For example-:
> Let us say object car has an attribute engine, then
> varname = "engine"
> car.varname = "dummy value"
> is giving me Error: object car does not have attribute varname.
> Please tell me how can I use variables as objects attributes.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list