Debian Codegraph @

tests/data/cases/slices.py

raw
1 slice[a.b : c.d]
2 slice[d :: d + 1]
3 slice[d + 1 :: d]
4 slice[d::d]
5 slice[0]
6 slice[-1]
7 slice[:-1]
8 slice[::-1]
9 slice[:c, c - 1]
10 slice[c, c + 1, d::]
11 slice[ham[c::d] :: 1]
12 slice[ham[cheese**2 : -1] : 1 : 1, ham[1:2]]
13 slice[:-1:]
14 slice[lambda: None : lambda: None]
15 slice[lambda x, y, *args, really=2, **kwargs: None :, None::]
16 slice[1 or 2 : True and False]
17 slice[not so_simple : 1 < val <= 10]
18 slice[(1 for i in range(42)) : x]
19 slice[:: [i for i in range(42)]]
20
21
22 async def f():
23 slice[await x : [i async for i in arange(42)] : 42]
24
25
26 # These are from PEP-8:
27 ham[1:9], ham[1:9:3], ham[:9:3], ham[1::3], ham[1:9:]
28 ham[lower:upper], ham[lower:upper:], ham[lower::step]
29 # ham[lower+offset : upper+offset]
30 ham[: upper_fn(x) : step_fn(x)], ham[:: step_fn(x)]
31 ham[lower + offset : upper + offset]