Python Anonymous Function: Difference between revisions

From GM-RKB
Jump to navigation Jump to search
m (Text replacement - "---- __NOTOC__" to "---- __NOTOC__")
m (Text replacement - ". ----" to ". ----")
 
Line 2: Line 2:
* <B>AKA:</B> [[Python Lambda/Unnamed Function]].
* <B>AKA:</B> [[Python Lambda/Unnamed Function]].
* <B>See:</B> [[Python Expression]], [[Python Function Definition]], [[AWS Lambda Function]].
* <B>See:</B> [[Python Expression]], [[Python Function Definition]], [[AWS Lambda Function]].
----
----
----
----

Latest revision as of 00:03, 23 September 2021

A Python Anonymous Function is a Python function that is an anonymous function.



References

2014

2013

 >>> def f (x): return x**2
 … 
 >>> print f(8)
 64
 >>> g = lambda x: x**2
 ...
 >>> print g(8)
 64
  • http://www.secnetix.de/olli/Python/lambda_functions.hawk
    • As you can see, f() and g() do exactly the same and can be used in the same ways. Note that the lambda definition does not include a "return" statement -- it always contains an expression which is returned. Also note that you can put a lambda definition anywhere a function is expected, and you don't have to assign it to a variable at all.

2012