The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Newsgroups: comp.lang.python
From: Robert Kern <robert.k...@gmail.com>
Date: Thu, 24 May 2007 00:05:02 -0500
Local: Thurs, May 24 2007 3:05 pm
Subject: Re: 0 == False but [] != False?
Rajarshi wrote: "if foo:" does not check if "foo == True" or "foo == False" but rather > This is a slightly naive question, but I know that 0 can be used to > represent False. So >>>> 0 == False > But, I know I can use [] to represent False as in >>>> if not []: print 'empty' > But then doing the following gives a surprising (to me!) result >>>> [] == False > Could anybody point out why this is the case? "bool(foo)". For empty lists, strings, tuples, dicts and some other things, "bool(foo) == False", while for lists, etc., with at least one element, "bool(foo) == True". -- "I have come to believe that the whole world is an enigma, a harmless enigma You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||