Newsgroups: comp.lang.python
From: Erik Max Francis <m...@alcyone.com>
Date: Wed, 23 May 2007 22:14:13 -0700
Local: Thurs, May 24 2007 3:14 pm
Subject: Re: 0 == False but [] != False?
Rajarshi wrote: Because "representing False" (i.e., being false) and "being the same as > 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? False" are not the same thing. if x: is not the same thing as if x == True: it's the same as if bool(x): So a more meaningful comparison of your two tests are: >>> bool(0) == bool(False) -- 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.
| ||||||||||||||