https://github.com/python/cpython/commit/da6c5d9818918a457fed11cf8cdccac91b00fc52
commit: da6c5d9818918a457fed11cf8cdccac91b00fc52
branch: 3.15
author: Miss Islington (bot) <[email protected]>
committer: methane <[email protected]>
date: 2026-10-30T12:22:08+09:00
summary:

Docs: fix generic class and comprehension examples (GH-160908)

(cherry picked from commit 83fe630f6f56da8acf0bb0c53639c6db30859461)

Co-authored-by: Inada Naoki <[email protected]>

files:
M Doc/reference/compound_stmts.rst
M Doc/reference/expressions.rst

diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst
index c13860eb3e9319a..7939b18306a2f28 100644
--- a/Doc/reference/compound_stmts.rst
+++ b/Doc/reference/compound_stmts.rst
@@ -1849,9 +1849,9 @@ The following example indicates the full set of allowed 
type parameter declarati
 
    def overly_generic[
       SimpleTypeVar,
-      TypeVarWithDefault = int,
       TypeVarWithBound: int,
       TypeVarWithConstraints: (str, bytes),
+      TypeVarWithDefault = int,
       *SimpleTypeVarTuple = (int, float),
       **SimpleParamSpec = (str, bytearray),
    ](
@@ -1952,7 +1952,7 @@ and decorators are evaluated outside that scope. This is 
illustrated
 by this example::
 
    @decorator
-   class Bag(Base[T], arg=T): ...
+   class Bag[T](Base[T], arg=T): ...
 
 This is equivalent to::
 
diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst
index 96b4e4872869047..61e84669423d5d2 100644
--- a/Doc/reference/expressions.rst
+++ b/Doc/reference/expressions.rst
@@ -703,9 +703,9 @@ For example, here is a set of lowercase letters::
 At run time, this corresponds roughly to calling this function::
 
    def make_lowercase_set(iterable):
-       result = set(iterable)
+       result = set()
        for x in iterable:
-           result.append(x.lower())
+           result.add(x.lower())
        return result
 
    make_lowercase_set(['a', 'A', 'b', 'C'])
@@ -726,7 +726,7 @@ At run time, this corresponds roughly to::
            result[func.__name__] = func
        return result
 
-   iterable([print, hex, any])
+   make_dict_mapping_names_to_functions([print, hex, any])
 
 As in other kinds of dictionary displays, the same key may be specified
 multiple times.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to