code review

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Jul 2 03:29:37 EDT 2012


On Sun, 01 Jul 2012 21:50:29 -0400, Devin Jeanpierre wrote:

> On Sun, Jul 1, 2012 at 9:28 PM, Steven D'Aprano
> <steve+comp.lang.python at pearwood.info> wrote:
>> Technically, < in Python is left-associative: a < b < c first evaluates
>> a, not b or c. But it is left-associative under the rules of comparison
>> operator chaining, not arithmetic operator chaining.
> 
> Left-associativity is when a < b < c is equivalent to (a < b) < c.
> 
> You're talking about evaluation order, which can be different. For
> example, hypothetically, (a < b) < c could evaluate c first, then b,
> then a. However, Python always evaluates operands left-to-right.
> 
> A particular case where this comes into play is the ** operator, which
> is right-associative but still has a left-to-right evaluation order.

Yes, you are right, my mistake.




-- 
Steven



More information about the Python-list mailing list