I have the following lambda function:
f = lambda x: x == None and '' or x
It should return an empty string if it receives None as the argument, or the argument if it's not None.
For example:
>>> f(4)
4
>>> f(None)
>>>
If I call f(None) instead of getting an empty string I get None. I printed the type of what the function returned and I got NoneType. I was expecting string.
type('') returns string, so I'd like to know why the lambda doesn't return an empty string when I pass None as an argument.
I'm fairly new to lambdas so I might have misunderstood some things about how they work.