forked from RustPython/RustPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassignment.py
More file actions
62 lines (45 loc) · 700 Bytes
/
assignment.py
File metadata and controls
62 lines (45 loc) · 700 Bytes
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
x = 1
assert x == 1
x = 1, 2, 3
assert x == (1, 2, 3)
x, y = 1, 2
assert x == 1
assert y == 2
x, y = (y, x)
assert x == 2
assert y == 1
((x, y), z) = ((1, 2), 3)
assert (x, y, z) == (1, 2, 3)
q = (1, 2, 3)
(x, y, z) = q
assert y == q[1]
x = (a, b, c) = y = q
assert (a, b, c) == q
assert x == q
assert y == q
a, *b = q
print(a)
print(b)
assert a == 1
assert b == [2, 3]
a, *b, c, d = q
print(a)
print(b)
assert a == 1
assert b == []
assert c == 2
assert d == 3
a, = [1]
assert a == 1
def g():
yield 1337
yield 42
a, b = g()
assert a == 1337
assert b == 42
# Variable annotations:
a: bool
b: bool = False
assert a == 1337
assert b == False
assert __annotations__['a'] == bool