summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/class_item.py
blob: 6061f26075d92c0fadad5bc05be77dc6a892f285 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
# test class with __getitem__ and __setitem__ methods

class C:
    def __getitem__(self, item):
        print('get', item)
        return 'item'

    def __setitem__(self, item, value):
        print('set', item, value)

c = C()
print(c[1])
c[1] = 2