aboutsummaryrefslogtreecommitdiff
path: root/Python Operators.wiki
blob: 09c168b47c5a91e74e01298a204f32a7e8462430 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
== Operators ==
https://docs.python.org/3/library/operator.html

{{{
< __lt__
<= __le__
== __eq__
!= __ne__
>= __ge__
> __gt_

+ __add__
// __floordiv__
~ __invert__
<< __lshift__
% __mod__
* __mul__
@ __matmul__
- (unary) __neg__
| __or__
+ (unary) __pos__
>> __rshift__
- __sub__
/ __truediv__
^ __xor__
+ (sequences) __concat__

+= __iadd__, __iconcat__
&= __iand__
//= __ifloordiv__
<<= __ilshift__
%= __imod__
*= __imul__
|= __ior__
**= __ipow__
>>= __irshift
-= __isub__
/= __itruediv__
^= __ixor__


** __pow__

in __contains__

& __and__


__abs__
}}}

{{{
__bool__
__str__
__repr__
}}}

== Order of operations ==
1. parenthesis
2. subscription_ call, attribute reference `x.attr`
3. `await`
4. `**`
5. Unary prefixes `+`, `-`, `~`
6. `*`, `@`, `/`, `//`, `%`
7. `+`, `+`
8. `<<`, `>>`
9. `&`
10. `^`
11. `|`
12. `in`, `not in` `is`, `is not`, and all comparison operators
13. `not` prefix
14. `and`
15. `or`
16. if-else expression
17. lambda
18. `:=`