On Sun, Dec 21, 2008 at 12:21, Mir Nazim <span dir="ltr"><<a href="mailto:mirnazim@gmail.com">mirnazim@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi guys, sorry for the off topic posting, but I know there are a<br>
couple of python guys on the list, so could not resist asking here<br>
Just a quick question.<br>
<br>
For example I have<br>
<br>
>>> class X<br>
>>> ....pass<br>
<br>
Then I do<br>
>>> x = X()<br>
>>> <a href="http://x.name" target="_blank">x.name</a> = 'Nazim<br>
<br>
Now my question is whether something like below is possible and how<br>
>>> y = 'name'<br>
>>> print x.y # How can x.y can be evaluated to <a href="http://x.name" target="_blank">x.name</a><br>
</blockquote><div><br>You can use:<br><br>print x.__dict__[y]<br><br>It will have the same result as:<br><br></div></div>print <a href="http://x.name">x.name</a><br><br><br>-- <br>Aditya Manthramurthy<br><br>