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: ...
|
||||
|
||||
This function will be called only if ``name`` is not found in the module
|
||||
through the normal attribute lookup. Looking up a name as a module global
|
||||
will bypass module ``__getattr__``. This is intentional, otherwise calling
|
||||
``__getattr__`` for builtins will significantly harm performance.
|
||||
If an attribute is not found on a module object through the normal lookup
|
||||
(i.e. ``object.__getattribute__``), then ``__getattr__`` is searched in
|
||||
the module ``__dict__`` before raising an ``AttributeError``. If found, it is
|
||||
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
|
||||
a list of strings that represents the names accessible on module::
|
||||
|
|
Loading…
Reference in New Issue