function expression with 2 arguments
Peter Hansen
peter at engcorp.com
Sat Feb 26 12:33:56 EST 2005
Xah Lee wrote:
> is there a way to write a expression of a function with more than 1
> argument?
>
> e.g., i want a expression that's equivalent to
>
> def f(x,y)
> return x+y
Since assignment is a statement in Python, not an expression,
and since "def f" is an assignment that binds a function
object to the name "f", you can't do exactly what you've
asked for.
On the other hand, this should be about equivalent, though
it's not merely an expression:
f = lambda x, y: x + y
More information about the Python-list
mailing list