I have the following lambda function:
f = lambda x: x == None and '' or x
It should return an empty string if it takes None as an argument, or an argument if it is not None.
For example:
>>> f(4) 4 >>> f(None) >>>
If I call f (None) instead of getting an empty string, I get None. I typed the type of the return function and got NoneType. I was expecting a string.
type ('') returns a string, so I would like to know why lambda does not return an empty string when I pass None as an argument.
I am new to lambdas, so I may have misunderstood some things about how they work.
python lambda
yoshi
source share