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: Raymond Hettinger <pyt...@rcn.com>
Date: 23 May 2007 22:09:48 -0700
Local: Thurs, May 24 2007 3:09 pm
Subject: Re: 0 == False but [] != False?
> >>> [] == False Writing, "if x" is short for writing "if bool(x)". > False > Could anybody point out why this is the case? Evaluating bool(x) checks for a x.__nonzero__() and if that method isn't defined, it checks for x.__len__() to see if x is a non-empty container. In your case, writing "if []" translates to True and False are of type bool which is a subclass In contrast, the empty list is not of type int. Raymond 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.
| ||||||||||||||