[Python-Dev] __dir__, part 2
Nick Coghlan
ncoghlan at gmail.com
Sun Nov 12 04:34:29 CET 2006
Fredrik Lundh wrote:
> Guido van Rossum wrote:
>
>> No objection on targetting 2.6 if other developers agree. Seems this
>> is well under way. good work!
>
> given that dir() is used extensively by introspection tools, I'm
> not sure I'm positive to a __dir__ that *overrides* the standard
> dir() behaviour. *adding* to the default dir() list is okay, re-
> placing it is a lot more questionable.
If a class only overrides __getattr__, then I agree it should only add to
__dir__ (most likely by using a super call as Georg suggests).
If it overrides __getattribute__, however, then it can actually deliberately
block access to attributes that would otherwise be accessible, so it may make
sense for it to alter the basic result of dir() instead of just adding more
attributes to the end.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
http://www.boredomandlaziness.org
More information about the Python-Dev
mailing list