Variable by label

Jarek Zgoda jzgoda at o2.usun.pl
Fri May 16 10:24:15 EDT 2008


rocco.rossi at gmail.com pisze:
> Is there any function which will return a variable by passing to it
> the string containing the variable's name? Something like this for
> instance:
> 
> foo = some_function("foo")
> 
> or perhaps it's a dictionary. I don't know, but I would really like to
> find out how it can be done. I guess it is achievable.

getattr(object, attrname, default)

-- 
Jarek Zgoda
Skype: jzgoda | GTalk: zgoda at jabber.aster.pl | voice: +48228430101

"We read Knuth so you don't have to." (Tim Peters)



More information about the Python-list mailing list