On Wed, Nov 15, 2017 at 5:49 PM, Guido van Rossum <guido at python.org> wrote: >> If not, why not, and if so, shouldn't PEP 562's __getattr__ also take a >> 'self'? > > Not really, since there's only one module (the one containing the > __getattr__ function). Plus we already have a 1-argument module-level > __getattr__ in mypy. See PEP 484. I guess the benefit of taking 'self' would be that it would make it possible (though still a bit odd-looking) to have reusable __getattr__ implementations, like: # mymodule.py from auto_importer import __getattr__, __dir__ auto_import_modules = {"foo", "bar"} # auto_importer.py def __getattr__(self, name): if name in self.auto_import_modules: ... -n -- Nathaniel J. Smith -- https://vorpus.org
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4