Is it really good?
Grant Edwards
grante at visi.com
Tue Jan 7 21:40:57 EST 2003
In article <slrnb1n3p0.n2l.grante at localhost.localdomain>, Grant Edwards wrote:
> In article <mailman.1041983572.25078.python-list at python.org>, Skip Montanaro wrote:
>>
>> Nadav> Can someone explain why python does not raise NameError in the
>> Nadav> first test line b[e]low.
>>
>> >>> 2 == 3 is good
>> 0 # ????????????????????????
>>
>> Chained operations. The above expression is effectively
>>
>> (2 == 3) and (3 is good)
>>
>> The first is false, so the second is never evaluated.
>
> Why do you say that?
>
> That logic would seem to indicate that
>
> 0 is 0
>
> should false, since the first term is false, the "is" short-circuits and
> returns false. It doesn't:
Never mind... I missed the whole chained operations point completely. I
have a really hard time remembering that
2 == 3 is good
evaluates as _neither_
(2 == 3) is good
nor
2 == (3 is good)
> All this still doesn't explain why
>
> (2==3) is good
>
> doesn't evaluate the right hand side of the "is"....
Except that it does:
>>> (2 == 3) is good
Traceback (most recent call last):
File "<stdin>", line 1, in ?
NameError: name 'good' is not defined
--
Grant Edwards grante Yow! Do I hear th'
at SPINNING of various
visi.com WHIRRING, ROUND, and WARM
WHIRLOMATICS?!
More information about the Python-list
mailing list