Skip to content

Commit da6c5d9

Browse files
Docs: fix generic class and comprehension examples (GH-160908)
(cherry picked from commit 83fe630) Co-authored-by: Inada Naoki <songofacandy@gmail.com>
1 parent cdba68e commit da6c5d9

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

‎Doc/reference/compound_stmts.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,9 +1849,9 @@ The following example indicates the full set of allowed type parameter declarati
18491849

18501850
def overly_generic[
18511851
SimpleTypeVar,
1852-
TypeVarWithDefault = int,
18531852
TypeVarWithBound: int,
18541853
TypeVarWithConstraints: (str, bytes),
1854+
TypeVarWithDefault = int,
18551855
*SimpleTypeVarTuple = (int, float),
18561856
**SimpleParamSpec = (str, bytearray),
18571857
](
@@ -1952,7 +1952,7 @@ and decorators are evaluated outside that scope. This is illustrated
19521952
by this example::
19531953

19541954
@decorator
1955-
class Bag(Base[T], arg=T): ...
1955+
class Bag[T](Base[T], arg=T): ...
19561956

19571957
This is equivalent to::
19581958

‎Doc/reference/expressions.rst‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -703,9 +703,9 @@ For example, here is a set of lowercase letters::
703703
At run time, this corresponds roughly to calling this function::
704704

705705
def make_lowercase_set(iterable):
706-
result = set(iterable)
706+
result = set()
707707
for x in iterable:
708-
result.append(x.lower())
708+
result.add(x.lower())
709709
return result
710710

711711
make_lowercase_set(['a', 'A', 'b', 'C'])
@@ -726,7 +726,7 @@ At run time, this corresponds roughly to::
726726
result[func.__name__] = func
727727
return result
728728

729-
iterable([print, hex, any])
729+
make_dict_mapping_names_to_functions([print, hex, any])
730730

731731
As in other kinds of dictionary displays, the same key may be specified
732732
multiple times.

0 commit comments

Comments
 (0)