You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A bare `*` marks every following parameter as keyword-only, positional args never reach them.
81
+
A bare `*` marks every following parameter as keyword-only; positional args never reach them.
82
82
83
83
```python
84
84
defconnect(host, *, port=80, secure=False):
@@ -142,7 +142,7 @@ Hi, world
142
142
143
143
## First-class functions
144
144
145
-
Functions are values, store, pass, return.
145
+
Functions are values: store, pass, return them.
146
146
147
147
```python
148
148
ops = [abs, len, str]
@@ -156,9 +156,9 @@ print([f(-3) for f in ops])
156
156
```python
157
157
# Functions as dict values; replaces switch/case
158
158
handlers = {
159
-
"add": lambdaa, b: a + b,
160
-
"mul": lambdaa, b: a * b,
161
-
"max": max,
159
+
"add": lambdaa, b: a + b,
160
+
"mul": lambdaa, b: a * b,
161
+
"max": max,
162
162
}
163
163
164
164
print(handlers["add"](3, 4))
@@ -343,11 +343,11 @@ Naive recursion runs at memoized cost without source-level changes.
343
343
344
344
```python
345
345
defsquares(n):
346
-
for i inrange(n):
347
-
yield i * i
346
+
for i inrange(n):
347
+
yield i * i
348
348
349
349
for x in squares(5):
350
-
print(x)
350
+
print(x)
351
351
```
352
352
353
353
```text Output
@@ -452,7 +452,7 @@ print(base(5))
452
452
12
453
453
```
454
454
455
-
Parameterised decorators are factories, a function taking decorator args and returning the actual decorator. The wrapped function captures both scopes.
455
+
Parameterised decorators are factories — a function taking decorator args and returning the actual decorator. The wrapped function captures both scopes.
0 commit comments