summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/assign_expr.py
blob: f243905dc2a63fe96fb2fe1f7bcea2094e507be8 (plain) (blame)
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
(x := 4)
print(x)

if x := 2:
    print(True)
print(x)

print(4, x := 5)
print(x)

x = 1
print(x, x := 5, x)
print(x)


def foo():
    print("any", any((hit := i) % 5 == 3 and (hit % 2) == 0 for i in range(10)))
    return hit


hit = 123
print(foo())
print(hit)  # shouldn't be changed by foo

print("any", any((hit := i) % 5 == 3 and (hit % 2) == 0 for i in range(10)))
print(hit)  # should be changed by above

print([((m := k + 1), k * m) for k in range(4)])
print(m)