New PEP: Attribute Access Handlers

Greg Ewing see at my.signature
Tue Jul 25 01:37:11 EDT 2000


Paul Prescod wrote:
> 
> __getattr__ will also take longer to get to until today.

But using __getattr__ is so horribly inefficient anyway, I don't
think anyone will notice.

> Okay, so let's say I have a get function but no set function. Won't the
> very first "set" put a variable in the dictionary so that future "gets"
> will fail according to the algorithm you described?

Doesn't that happen now if you have a __getattr__ but
no __setattr__? If it's a problem in a given case, the
solution would seem to be to provide a set method.
("Don't do that, then!")

The opposite situation -- a set method but no get
method -- is probably going to be more common, and
will work correctly (provided the implementation
doesn't purloin the dict slot for the attribute name
itself).

-- 
Greg Ewing, Computer Science Dept, University of Canterbury,	  
Christchurch, New Zealand
To get my email address, please visit my web page:	  
http://www.cosc.canterbury.ac.nz/~greg



More information about the Python-list mailing list