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
Copy file name to clipboardExpand all lines: concepts/decorators/about.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,7 @@ def decorated_function2():
31
31
pass
32
32
```
33
33
34
-
If a decorator has defined default arguments, you must use parenthesis in the `@decorator()` call for the decorator to work:
34
+
If a decorator has defined default arguments, you must use parenthesis in the `@decorator()` call for the decorator to work, as you would in calling any function:
35
35
36
36
```python
37
37
@decorator_with_default_arg()
@@ -152,8 +152,8 @@ The inner function returns either `func` or, if `planet` equals `Pluto`, it will
152
152
It could be coded to raise a `ValueError` instead.
153
153
So, the inner function wraps `func`, and returns either `func` or does something that substitutes what `func` would do.
154
154
The decorator returns its _inner function_.
155
-
It does not _directly_ return the original, passed-in function.
156
-
Depending on what happens in the wrapper function, `func` may or may not be returned.
155
+
The _inner_function_ may or may not return the original, passed-in function.
156
+
Depending on what code conditionally executes in the wrapper function or _inner_function_, `func` may be returned, an error could be raised, or a value of `func`'s return type could be returned.
157
157
158
158
### Decorating a Function that Takes an Arbitrary Number of Arguments
159
159
@@ -178,7 +178,7 @@ Following is an example of a decorator for a function that takes an arbitrary nu
178
178
```
179
179
180
180
This works for doubling the return value from the function argument.
181
-
If we want to triple, quadruple, etc. the return value, we can add a parameter to the decorator itself., as we show in the next section.
181
+
If we want to triple, quadruple, etc. the return value, we can add a parameter to the decorator itself, as we show in the next section.
0 commit comments