Clarification based on python-dev discussion (#480)
This commit is contained in:
parent
303e46d494
commit
9228c0c923
11
pep-0562.rst
11
pep-0562.rst
|
@ -113,10 +113,13 @@ an ``AttributeError``::
|
||||||
|
|
||||||
def __getattr__(name: str) -> Any: ...
|
def __getattr__(name: str) -> Any: ...
|
||||||
|
|
||||||
This function will be called only if ``name`` is not found in the module
|
If an attribute is not found on a module object through the normal lookup
|
||||||
through the normal attribute lookup. Looking up a name as a module global
|
(i.e. ``object.__getattribute__``), then ``__getattr__`` is searched in
|
||||||
will bypass module ``__getattr__``. This is intentional, otherwise calling
|
the module ``__dict__`` before raising an ``AttributeError``. If found, it is
|
||||||
``__getattr__`` for builtins will significantly harm performance.
|
called with the attribute name and the result is returned. Looking up a name
|
||||||
|
as a module global will bypass module ``__getattr__``. This is intentional,
|
||||||
|
otherwise calling ``__getattr__`` for builtins will significantly harm
|
||||||
|
performance.
|
||||||
|
|
||||||
The ``__dir__`` function should accept no arguments, and return
|
The ``__dir__`` function should accept no arguments, and return
|
||||||
a list of strings that represents the names accessible on module::
|
a list of strings that represents the names accessible on module::
|
||||||
|
|
Loading…
Reference in New Issue