x = None
result = (x is None and "" or str(x))
print result, type(result)
---------------
OUTPUT
---------------
None <type 'str'>
y = 5
result = (y is 5 and "it's five" or "it's not five")
print result
-------------
OUTPUT
-------------
it's five
....what's wrong with the first operation I did with x? I was expecting
"result" to be an empty string, not the str value of None.
result = (x is None and "" or str(x))
print result, type(result)
---------------
OUTPUT
---------------
None <type 'str'>
y = 5
result = (y is 5 and "it's five" or "it's not five")
print result
-------------
OUTPUT
-------------
it's five
....what's wrong with the first operation I did with x? I was expecting
"result" to be an empty string, not the str value of None.
Comment