Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
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.
| Operator | Int | long | float | complex | string | list | tuple | dictionary |
|---|---|---|---|---|---|---|---|---|
| [] | • | • | • | |||||
| [:] | • | • | • | |||||
| ** | • | • | • | • | ||||
| +† | • | • | • | • | ||||
| -† | • | • | • | • | ||||
| ~† | • | • | ||||||
| * | • | • | • | • | • | • | • | |
| / | • | • | • | • | ||||
| % | • | • | • | • | • | |||
| + | • | • | • | • | • | • | • | |
| - | • | • | • | • | ||||
| << | • | • | ||||||
| >> | • | • | ||||||
| & | • | • | ||||||
| ^ | • | • | ||||||
| | | • | • | ||||||
| < | • | • | • | • | • | • | • | • |
| > | • | • | • | • | • | • | • | • |
| <= | • | • | • | • | • | • | • | • |
| >= | • | • | • | • | • | • | • | • |
| == | • | • | • | • | • | • | • | • |
| != | • | • | • | • | • | • | • | • |
| <> | • | • | • | • | • | • | • | • |
| is | • | • | • | • | • | • | • | • |
| is not | • | • | • | • | • | • | • | • |
| in | • | • | • | |||||
| not in | • | • | • | |||||
| not† | • | • | • | • | • | • | • | • |
| and | • | • | • | • | • | • | • | • |
| or | • | • | • | • | • | • | • | • |