Operator precedence problem
Random832
random832 at fastmail.com
Sun Jun 5 13:19:33 EDT 2016
More information about the Python-list mailing list
Sun Jun 5 13:19:33 EDT 2016
- Previous message (by thread): Operator precedence problem
- Next message (by thread): Operator precedence problem
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sun, Jun 5, 2016, at 02:53, ICT Ezy wrote: > >>> 2 ** 3 ** 2 > Answer is 512 > Why not 64? > Order is right-left or left-right? You're mixing up order of evaluation with operator associativity. The ** operator is right-to-left associative, this means x ** y ** z == x ** (y ** z). Evaluation is left to right, where it matters [i.e. if one or more of the elements here were an expression with side effects]: first x is evaluated, then tmp=y**z, then x**tmp. These are two entirely different concepts.
- Previous message (by thread): Operator precedence problem
- Next message (by thread): Operator precedence problem
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list