a = b = 1 just syntactic sugar?
Christopher A. Craig
com-nospam at ccraig.org
Tue Jun 3 10:14:57 EDT 2003
Kendear <kendear at nospam.com> writes:
> if Python supports 1 < a < 10
> then maybe it is also just syntactic sugar.
> Other language might take it as (1 < a) < 10
> which is just the boolean 0 or 1 less than 10
> which is always true.
>
> >>> a = -1
> >>> 1 < a < 10
> 0
> >>> (1 < a) < 10
> 1
>
> so in Python, we can't just add parenthesis
> to multiple = and can't add parenthesis
> arbitrarily to multiple <, >, ==, etc.
Sure you can. It just totally changes the meaning.
1 < a < 10 is the same as 1<a and a<10
(1<a) < 10 is not
--
Christopher A. Craig <com-nospam at ccraig.org>
"The mistakes made by Congress wouldn't be so bad if the next Congress
didn't keep trying to correct them." Cullen Hightower
More information about the Python-list
mailing list