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 <br><br><div class="gmail_quote">On Mon, Aug 16, 2010 at 7:10 PM, Vikas Mahajan <span dir="ltr"><<a href="mailto:vikas.mahajan12@gmail.com">vikas.mahajan12@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hello to all<br>
<br>
I am new to python. I am facing problem to use variables as object<br>
attributes. I have to use loop and dynamically add attributes to a<br>
object and for this purpose I have to use variables with object names.<br>
<br>
For example-:<br>
Let us say object car has an attribute engine, then<br>
varname = "engine"<br>
car.varname = "dummy value"<br>
is giving me Error: object car does not have attribute varname.<br>
<br>
Please tell me how can I use variables as objects attributes.<br>
<br>
Thanks.<br>
<font color="#888888">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Nitin Pawar<br><br>