blueberryfields
blueberryfields

Reputation: 50458

Is it possible to specify a default value for a parameter to a lambda expression in Python?

Is the following correct Python code? If not, what's the correct syntax for this kind of expression?

x = lambda (y, z=None) : y if z == None else z

Upvotes: 2

Views: 104

Answers (1)

Pavel Anossov
Pavel Anossov

Reputation: 62938

You don't need the parentheses:

x = lambda y, z=None: y if z is None else z

Upvotes: 3

Related Questions