[issue12248] __dir__ semantics changed in Python 2.7.2

Nick Coghlan report at bugs.python.org
Fri Jun 3 02:14:52 CEST 2011


Nick Coghlan <ncoghlan at gmail.com> added the comment:

Hmm, that behaviour looks unrelated to the specific problem Michael reported.

The initial problem in this space was that defining __dir__() completely determined the result of dir() calls, but object.__dir__() didn't actually work, so you couldn't easily get the standard list of attributes in order to supplement it.

I don't believe there is any reason to have tightened up the type constraints while fixing that - dir() should be returning sorted(obj.__dir__()) and not caring about the exact return type of the magic method.

----------
nosy: +ncoghlan

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12248>
_______________________________________


More information about the Python-bugs-list mailing list