Skip to content

Commit 011ba37

Browse files
author
Guido van Rossum
committed
Show positional-only args in cheat sheet
1 parent 1ede9cf commit 011ba37

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

docs/source/cheat_sheet.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ Functions
7777
# type: (int, float) -> float
7878
return num1 + my_float
7979
80+
# An argument can be declared positional-only by giving it a name
81+
# starting with two underscores:
82+
def quux(__x):
83+
# type: (int) -> None
84+
pass
85+
quux(3) # Fine
86+
quux(__x=3) # Error
87+
8088
# This is how you annotate a function value.
8189
x = f # type: Callable[[int, float], float]
8290

docs/source/cheat_sheet_py3.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ Python 3 introduces an annotation syntax for function declarations in `PEP 3107
7373
def f(num1: int, my_float: float = 3.5) -> float:
7474
return num1 + my_float
7575
76+
# An argument can be declared positional-only by giving it a name
77+
# starting with two underscores:
78+
def quux(__x: int) -> None:
79+
pass
80+
quux(3) # Fine
81+
quux(__x=3) # Error
82+
7683
# This is how you annotate a function value.
7784
x = f # type: Callable[[int, float], float]
7885

0 commit comments

Comments
 (0)