Re: Get attribute this way

2009-11-17 Thread Bruno Desthuilliers
King a écrit : Python's getattr, setattr and __getattribute__ commands s/commands/functions/ works fine with python types. For example: print o.__getattribute__("name") A very few corner cases set aside - the main one being inside a custom __getattribute__ method -, you should not directly

Re: Get attribute this way

2009-11-17 Thread Carl Banks
On Nov 16, 11:37 pm, King wrote: > "eval" can solve this problem right away but I am concerned about > security issues. If not "eval" could you suggest something more > efficient way. It won't be a big deal to change the format as > application is still at development stage? You are stuck parsin

Re: Get attribute this way

2009-11-17 Thread Diez B. Roggisch
King schrieb: "eval" can solve this problem right away but I am concerned about security issues. If not "eval" could you suggest something more efficient way. It won't be a big deal to change the format as application is still at development stage? If you don't want to use eval (which is a good

Re: Get attribute this way

2009-11-16 Thread King
"eval" can solve this problem right away but I am concerned about security issues. If not "eval" could you suggest something more efficient way. It won't be a big deal to change the format as application is still at development stage? Thanks Prashant Python 2.6.2 Win XP 32 -- http://mail.python.

Re: Get attribute this way

2009-11-16 Thread Chris Rebert
On Mon, Nov 16, 2009 at 10:53 PM, King wrote: > Writing/Reading data to xml is not a problem. The problem is when I > have to write to attributes in xml, where a connections has been > established. > XML: > destattribute="node2.gradient.colors[1][2]"/> You did not include an example like this in

Re: Get attribute this way

2009-11-16 Thread King
Writing/Reading data to xml is not a problem. The problem is when I have to write to attributes in xml, where a connections has been established. XML: While reading back I have to convert both source and destination strings into object so that I can call connections function using source and targ

Re: Get attribute this way

2009-11-16 Thread Chris Rebert
On Mon, Nov 16, 2009 at 10:04 PM, King wrote: > Python's getattr, setattr and __getattribute__ commands works fine > with python types. > For example: > print o.__getattribute__("name") > print getattr(o, "name") > This is the easiest way to get an attribute using a string. > > In my case the "Nod

Get attribute this way

2009-11-16 Thread King
Python's getattr, setattr and __getattribute__ commands works fine with python types. For example: print o.__getattribute__("name") print getattr(o, "name") This is the easiest way to get an attribute using a string. In my case the "Node" class load/creates all the attributes from a xml file. Exam