What values are considered false?

Remco Gerlich scarblac at pino.selwerd.nl
Sun Feb 24 11:45:25 EST 2002


Jeff Henry <jhenry19 at ford.com> wrote in comp.lang.python:
> 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()):

No, he didn't. He thought the *function* should be false, not the function's
result. An interesting idea, but possibly hard to implement (write code to
decide if a function does nothing). Also, I haven't been able to come up
with any situation where it would be useful yet :-)

-- 
Remco Gerlich



More information about the Python-list mailing list