Operator precedence
The following table summarizes the operator precedences in Python, from lowest precedence (least binding) to highest precedence (most binding). Operators in the same box have the same precedence. Unless the syntax is explicitly given, operators are binary. Operators in the same box group left to right (except for comparisons, including tests, which all have the same precedence and chain from left to right — see section Comparisons — and exponentiation, which groups from right to left).
Operator | Description |
---|---|
lambda | Lambda expression |
if – else | Conditional expression |
or | Boolean OR |
and | Boolean AND |
not x | Boolean NOT |
in, not in, is, is not, <, <=, >, >=, <>, !=, == | Comparisons, including membership tests and identity tests |
| | Bitwise OR |
^ | Bitwise XOR |
& | Bitwise AND |
<<, >> | Shifts |
+, - | Addition and subtraction |
*, /, //, % | Multiplication, division, remainder [8] |
+x, -x, ~x | Positive, negative, bitwise NOT |
** | Exponentiation [9] |
x[index], x[index:index], x(arguments...), x.attribute | Subscription, slicing, call, attribute reference |
(expressions...), [expressions...], {key: value...}, `expressions...` | Binding or tuple display, list display, dictionary display, string conversion |
출처
https://docs.python.org/2/reference/expressions.html#operator-precedence
'Parametric Design > 21. Python 툴팁' 카테고리의 다른 글
Built-in Functions in Python (0) | 2015.06.14 |
---|---|
Loop Mechanisms in Python (0) | 2015.06.13 |
More Syntax, Keywords, Functions, Variable Scope (0) | 2015.06.13 |
Capitalization, Indentation, String Splicing (0) | 2015.06.13 |
[기초] Python in operator와 Advance S (0) | 2015.06.13 |