Jump to content

Function definition: Difference between revisions

callable
(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}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.