Builtin Types and Operators
Operators and Precedence
Table 11 lists Python’s expression operators. Operators in the lower cells of this table have higher precedence (i.e., bind tighter) when used in mixedoperator expressions without parentheses.
Table 11. Python 3.0 expression operators and precedence
Operator  Description 

 Generator function

 Anonymous function maker 
 Ternary selection
( 
 Logical 
 Logical 
 Logical negation 
 Membership: iterables, sets 
 Object identity tests 
 Magnitude comparisons, set subset and superset 
X == Y , X != Y  Equality operators 
 Bitwise 
 Bitwise exclusive

 Bitwise 
 Shift 
 Addition/concatenation, subtraction/set difference 
 Multiplication/repetition, remainder/format, division, floor division 
 Unary negation, identity 
 Bitwise NOT complement (inversion) 
 Power (exponentiation) 
 Indexing (sequence, mapping, others) 
 Slicing (all bounds optional) 
 Call (function, method, class, other callable) 
 Attribute reference 
 Tuple, expression, generator expression 
 List, list comprehension 
 Dictionary, set, dictionary and set comprehension 
Operator Usage Notes
In Python 2.6, ...
Get Python Pocket Reference, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.