I've pondered two PEPs that are in (friendly) competition with each other: - PEP 549 -- Instance Descriptors (Larry Hastings) - PEP 562 -- Module __getattr__ (Ivan Levkivskyi) In the end I am *rejecting* PEP 549 and I hope to *accept* PEP 562, with a small addition to the latter to also support overriding __dir__ (so that one can provide a __dir__ implementation that matches the __getattr__ implementation, or perhaps counteracts it, in case one wants deprecated attributes to be omitted from dir() but still usable). The __dir__ addition is mentioned here: https://github.com/ilevkivskyi/cpython/pull/3#issuecomment-343591293 . A bit more motivation for my choice: re-reading PEP 549 reminded me of how its implementation is remarkably subtle (invoking Armin Rigo; for more details read https://www.python.org/dev/peps/pep-0549/#implementation). On the contrary, the implementation of PEP 562 is much simpler. With the Zen of Python in mind, this gives a hint that it is the better idea, and possibly even a good idea. Ivan, once you've added the __dir__ thing to your PEP, please post it to python-dev to solicit review from its (larger) readership. -- --Guido van Rossum (python.org/~guido)
participants (1)
-
Guido van Rossum