]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Docs: improve generic `typing.NamedTuple` example (#124739)
authorCBerJun <121291537+CBerJun@users.noreply.github.com>
Sun, 29 Sep 2024 11:07:05 +0000 (07:07 -0400)
committerGitHub <noreply@github.com>
Sun, 29 Sep 2024 11:07:05 +0000 (12:07 +0100)
Doc/library/typing.rst

index 640bc2c9d503bc8f6ddf4a29f72a04fd34bc8fea..cd8b90854b0e94330d6d92cdddb17c7b2748b51b 100644 (file)
@@ -2349,7 +2349,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]