Appendix C. Python Operator Summary

Table C.1 represents the complete set of Python operators and to which standard types they apply. The operators are sorted from highest-to-lowest precedence, with those sharing the same shaded group having the same priority.

Table C.1. Python Operators († - unary)
OperatorIntlongfloatcomplexstringlisttupledictionary
[]     
[:]     
**    
+†    
-†    
~†      
* 
/    
%   
+ 
-    
<<      
>>      
&      
^      
|      
<
>
<=
>=
==
!=
<>
is
is not
in     
not in     
not†
and
or

Get Core Python Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.