[complaint]Re: SomeClassInstance.[attributename]

Stephan Effelsberg b012414 at mail.dvz.fh-koeln.de
Mon Nov 6 16:17:57 CET 2000

tattoom at my-deja.com schrieb:

> Hello,Please excuse my ignorance...Python does provide a built-in function to
> check for the existence of an object's attribute:  hasattr(object, name)What
> puzzles me to no end, is the fact one straight (IMHO) corollary to the above
> functionality doesn't seem to exist (at least I can't find it :-).Namely, the
> possibility to access an instance's attribute in a 'parameterized' (is that a
> correct word?) way..e.g. Assume that Foo is an instance of some
> class:theAttribute = 'fubar'if hasattr(Foo, theAttribute):  fubar =
> Foo.[theAttribute]# Where Foo.[theAttribute] would yield Foo.fubarYou get my
> point. Is there a way in Python (as elegant and straightforward as this one)
> to achieve the above?If not, I'd be interested in seeing suggestions on how
> to implement it.Many TIA= tmk =
> Sent via Deja.com http://www.deja.com/
> Before you buy.

Could you please make extensive use of
and     t    a    b    s
where appropriate to give your question some structure?
Thank you.

More information about the Python-list mailing list