mirror of
https://github.com/python/cpython.git
synced 2025-12-11 11:31:05 +00:00
gh-114071: [Enum] update docs and code for tuples/subclasses (GH-114871)
Update documentation with `__new__` and `__init__` entries.
Support use of `auto()` in tuple subclasses on member assignment lines. Previously, auto() was only supported on the member definition line either solo or as part of a tuple:
RED = auto()
BLUE = auto(), 'azul'
However, since Python itself supports using tuple subclasses where tuples are expected, e.g.:
from collections import namedtuple
T = namedtuple('T', 'first second third')
def test(one, two, three):
print(one, two, three)
test(*T(4, 5, 6))
# 4 5 6
it made sense to also support tuple subclasses in enum definitions.
This commit is contained in:
parent
ec69e1d0dd
commit
ff7588b729
4 changed files with 69 additions and 5 deletions
|
|
@ -0,0 +1 @@
|
|||
Support tuple subclasses using auto() for enum member value.
|
||||
Loading…
Add table
Add a link
Reference in a new issue