mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
Issue #21205: Add a new `__qualname__
` attribute to generator, the qualified
name, and use it in the representation of a generator (``repr(gen)``). The default name of the generator (``__name__`` attribute) is now get from the function instead of the code. Use ``gen.gi_code.co_name`` to get the name of the code.
This commit is contained in:
parent
26171993fe
commit
40ee30181f
7 changed files with 171 additions and 24 deletions
|
@ -159,6 +159,16 @@ attributes:
|
|||
| | | arguments and local |
|
||||
| | | variables |
|
||||
+-----------+-----------------+---------------------------+
|
||||
| generator | __name__ | name |
|
||||
+-----------+-----------------+---------------------------+
|
||||
| | __qualname__ | qualified name |
|
||||
+-----------+-----------------+---------------------------+
|
||||
| | gi_frame | frame |
|
||||
+-----------+-----------------+---------------------------+
|
||||
| | gi_running | is the generator running? |
|
||||
+-----------+-----------------+---------------------------+
|
||||
| | gi_code | code |
|
||||
+-----------+-----------------+---------------------------+
|
||||
| builtin | __doc__ | documentation string |
|
||||
+-----------+-----------------+---------------------------+
|
||||
| | __name__ | original name of this |
|
||||
|
@ -169,6 +179,10 @@ attributes:
|
|||
| | | ``None`` |
|
||||
+-----------+-----------------+---------------------------+
|
||||
|
||||
.. versionchanged:: 3.5
|
||||
|
||||
Add ``__qualname__`` attribute to generators.
|
||||
|
||||
|
||||
.. function:: getmembers(object[, predicate])
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue