SomeClassInstance.[attributename]
tattoom at my-deja.com
tattoom at my-deja.com
Tue Nov 7 02:06:19 EST 2000
[snip]
> can be more concisely, clearly, & speedily expressed as just:
>
> fubar = getattr(Foo, theAttribute, 23)
>
> Alex
>
>
Thanks a lot Alex (and Hrvoje) for taking the time to decipher my post and
pointing to the obvious getattr.
This may be syntactic shugar but I was too much focused on not being able to
write:
Foo.[Fubar].[Toto].[Tata]
rather than
getattr(getattr(getattr(Foo, Fubar), Toto), Tata)
to walk an object hierarchy.
I've grown so fond of Python that I've come to expect too much from it :-)
= tmk =
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list
mailing list