[Python-Dev] Comment on PEP 562 (Module __getattr__ and __dir__)
Mark Shannon
mark at hotpy.org
Sun Nov 19 15:24:00 EST 2017
Hi,
Just one comment. Could the new behaviour of attribute lookup on a
module be spelled out more explicitly please?
I'm guessing it is now something like:
`module.__getattribute__` is now equivalent to:
def __getattribute__(mod, name):
try:
return object.__getattribute__(mod, name)
except AttributeError:
try:
getter = mod.__dict__["__getattr__"]
except KeyError:
raise AttributeError(f"module has no attribute '{name}'")
return getter(name)
Cheers,
Mark.
More information about the Python-Dev
mailing list