|
2 | 2 | The Trouble (Or Lack Thereof) With Lambda |
3 | 3 | ***************************************** |
4 | 4 |
|
5 | | -:ref:`Lambda` expressions are a common and useful part of the Python programming language. |
| 5 | +Lambda expressions are a common and useful part of the Python programming language. |
6 | 6 | However, there is one problem with them: syntactically, they do not allow for type |
7 | 7 | annotations. While it is perfectly simple to write ``lambda x: x``, you cannot directly |
8 | 8 | indicate a type for x. (Type annotations are indicated by a colon, and so is the end |
@@ -33,12 +33,12 @@ you might as well just define a normal function. Let's call that our first worka |
33 | 33 | ``def f(x: object) -> object: return x`` |
34 | 34 |
|
35 | 35 | The second workaround is equivalent: assigning the lambda to a variable, and annotating |
36 | | -the type of that variable with a :ref:`Callable` |
| 36 | +the type of that variable with a Callable. |
37 | 37 |
|
38 | 38 | ``f: Callable[[object], object] lambda x: x`` |
39 | 39 |
|
40 | | -:ref:`Type comments on function definitions` do not actually work on lambda, nor do |
41 | | -normal :ref:`Type comments` help (although you can use a type commment on an assignment |
| 40 | +Type comments on function definitions do not actually work on lambda, nor do |
| 41 | +normal type comments help (although you can use a type commment on an assignment |
42 | 42 | to a variable with a lambda, of course; however this will have to be the Callable |
43 | 43 | syntax and not the function-arrow special one). |
44 | 44 |
|
|
0 commit comments