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: Tim Roberts <t...@probo.com>
Date: Thu, 24 May 2007 06:59:32 GMT
Local: Thurs, May 24 2007 4:59 pm
Subject: Re: 0 == False but [] != False?
Rajarshi <rajarshi.g...@gmail.com> wrote: False is just a constant. 0, (), '', [], and False are all constants that >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? happen to evaluate to a false value in a Boolean context, but they are not all the same. As a general rule, I've found code like "if x == False" to be a bad idea in 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.
| ||||||||||||||