Emulating a = x.y and x.y = a, when 'y' is a string

Bruce Dawson bruce_deletethis_dawson at cygnus-software.com
Fri Oct 18 00:51:39 EDT 2002


Michael Hudson wrote:

> Bruce Dawson <bruce_deletethis_dawson at cygnus-software.com> writes:
> 
>>I want to do dynamic access to member variables in Python - reading
>>from and writing to object member variables based on a member name
>>stored in a string. If the member is stored in __dict__ it is easy
>>enough, but what if it is emulated with __getattr__, or a property, or
>>__getattribute__?
>>
> 
> I think you're looking for the builtin functions getattr and setattr.


I sure am. Thanks. That's perfect.

How come we never noticed those before? Perhaps because they are global, 
and we were looking for member functions. Ah well - we know them now.

Thanks.

 
> Cheers,
> M.
> 
> 




More information about the Python-list mailing list