summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/slice_attrs.py
blob: 67456ff8e6c0dd8978060a769910611ab1d15ed5 (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
# test builtin slice attributes access

# print slice attributes
class A:
    def __getitem__(self, idx):
        print(idx.start, idx.stop, idx.step)

try:
    t = A()[1:2]
except:
    import sys
    print("SKIP")
    sys.exit()


A()[1:2:3]

# test storing to attr (shouldn't be allowed)
class B:
    def __getitem__(self, idx):
        try:
            idx.start = 0
        except AttributeError:
            print('AttributeError')
B()[:]