aboutsummaryrefslogtreecommitdiff
path: root/Python Operators.wiki
blob: fae6364a5f28388e889b2fe056dd28a2125a1b22 (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
== Operators ==
{{{
< __lt__
<= __le__
== __eq__
!= __ne__
>= __ge__
> __gt_

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

** __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. `:=`