Philosophical Python: 2*b or not 2*b

Andreas Neudecker zapyon at gmx.net
Thu Oct 27 04:11:15 EDT 2011


Not the answers I expected:
;-)

>>> b = True
>>> 2*b or not 2*b
2

>>> b = False
>>> 2*b or not 2*b
True


It all becomes clear when you look at:

>>> b = False
>>> 2*b
0

>>> b = True
>>> 2*b
2

No surprise there really. But fun anyway.

Any more philsophical Python code out there?




More information about the Python-list mailing list