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
The body of a lambda expression is just a function call on the same argument list as the lambda itself. The lambda is probably unnecessary. Improve code readability by removing the lambda and calling the function directly on the argument list.
8
+
9
+
Description
10
+
-----------
11
+
12
+
Lambda expressions enable you to create inline, anonymous functions. A lambda serves no purpose when it is just a call to a named function. It only makes the code harder to read.
13
+
14
+
Examples
15
+
----------
16
+
17
+
Lambda is just a function call
18
+
..............................
19
+
20
+
The lambda expression below does nothing other than call the function ``multiply_by_two()``. In this situation the lambda is pointless and only makes the code harder to read.
21
+
22
+
.. warning:: The code below is an example of an error. Using this code will create bugs in your programs!
The modified module below has removed the unnecessary lambda and just calls the ``multiply_by_two()`` function directly. This code is more direct and more concise than the original code that used a lambda.
0 commit comments