mirror of https://github.com/python/cpython
Docs: improve generic `typing.NamedTuple` example (#124739)
This commit is contained in:
parent
3f27153e07
commit
76fbee642e
|
@ -2349,7 +2349,9 @@ types.
|
||||||
|
|
||||||
Backward-compatible usage::
|
Backward-compatible usage::
|
||||||
|
|
||||||
# For creating a generic NamedTuple on Python 3.11 or lower
|
# For creating a generic NamedTuple on Python 3.11
|
||||||
|
T = TypeVar("T")
|
||||||
|
|
||||||
class Group(NamedTuple, Generic[T]):
|
class Group(NamedTuple, Generic[T]):
|
||||||
key: T
|
key: T
|
||||||
group: list[T]
|
group: list[T]
|
||||||
|
|
Loading…
Reference in New Issue