What values are considered false?

Roy Smith roy at panix.com
Wed Feb 20 23:20:45 EST 2002


Roy Smith <roy at panix.com> wrote:
> PS -- In the lists of false things in python that have been mentioned on 
> this thread, I don't think I've seen anybody mention {}, the empty 
> dictionary.

Along those same lines, I half-expected the empty function to be false, 
i.e.:

def foo():
   pass

if (foo):
   print "it's true"
else:
   print "it's false"

should have printed "it's false".  Alas, it says it's true.  Seems kind of 
irregular to me, not that I would imagine there's much practical 
consequence one way or the other.



More information about the Python-list mailing list