mirror of
https://github.com/python/cpython.git
synced 2026-01-07 16:02:55 +00:00
[3.13] Docs: improve generic typing.NamedTuple example (GH-124739) (#124764)
Docs: improve generic `typing.NamedTuple` example (GH-124739)
(cherry picked from commit 76fbee642e)
Co-authored-by: CBerJun <121291537+CBerJun@users.noreply.github.com>
This commit is contained in:
parent
7c7e01c2a1
commit
e532760f46
1 changed files with 3 additions and 1 deletions
|
|
@ -2273,7 +2273,9 @@ types.
|
|||
|
||||
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]):
|
||||
key: T
|
||||
group: list[T]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue