What values are considered false?

Harvey Thomas hst at empolis.co.uk
Thu Feb 21 12:24:55 EST 2002


The empty function is not only false, it is also None

In the interpreter,

def foo():pass

foo() is None

1

> -----Original Message-----
> From: Jeff Henry [mailto:jhenry19 at ford.com]
> Sent: 21 February 2002 16:27
> To: python-list at python.org
> Subject: Re: What values are considered false?
> 
> 
> Roy Smith wrote:
> > 
> > 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):
> 
> Oops! I think you meant to say -
> 
> 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.
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 

_____________________________________________________________________
This message has been checked for all known viruses by the MessageLabs Virus Scanning Service.




More information about the Python-list mailing list