Function definition: Difference between revisions
Content deleted Content added
Python |
callable |
||
Line 39:
Unnamed function:
multiply = lambda a, b: a * b
A callable - may be useful to allow both simple functions and complex classes to use the same interface:
<pre>
>>> class Multiply:
... def __call__(self, a, b):
... return a * b
...
>>> multiply = Multiply()
>>> multiply(3, 4)
12
<pre>
=={{header|Toka}}==
|