question about True values

Georg Brandl g.brandl-nospam at gmx.net
Sun Oct 29 04:24:36 EST 2006


Chetan wrote:

>>> I am joining after some network downtime here, so I seem to have missed what
>>> the real issue here is. At the risk of being completely irrelevant to the
>>> discussion here, I think it doesn't seem to be just about something or
>>> nothing - is None something or nothing? It seems to be neither:
>>
>> If is, of course, nothing. You may have misunderstood the semantics of the
>> "and" and "or" operators.
> 
> I have not. I just posted another message on the subject. All I am trying to
> point out is that the "nothingness" evaluation does not occur at the level of
> expressions. It is only when the expression is needed to make decisions about
> control flow that this comes into picture. 

This is not correct. "and" and "or" involve truth (or "somethingness") 
evaluation, as you can see from this example:

Python 2.5 (r25:51908, Sep 22 2006, 10:45:03)
 >>> class A:
...     def __nonzero__(self):
...         print "nonzero"
...         return True
...
 >>> A() and 1
nonzero
1
 >>>

Georg



More information about the Python-list mailing list