[Edu-sig] Interesting "gotcha"

Christian Mascher christian.mascher at gmx.de
Tue Mar 29 17:12:46 CEST 2011


Hi,

I really like it that python allows me to write

if 10 < x <=  b:
     ...

impossible in many other languages.
But all things come at a cost:

> 
>   if x > y == True:
> 

I think this is a real gotcha, because it might get you, because you 
_know too much_:
 >>> if 4:
	print True

	
True
 >>>
So all things different from 0, '', ... are considered True by python.
But.....

spoiler ahead ;-)
 >>> 4==True

False
 >>>

Cheers

Christian


More information about the Edu-sig mailing list