class Foo(object):

    def __getitem__(self, index):
        print('Getting', index)

def __setitem__(self, index, val):
    print('Setting', index, 'to', val)
f = Foo()
print('Getting...')
f[:]
f[4:10, ::-1, ...]
print('Equivalently:')
f.__getitem__(slice(None))
f.__getitem__((slice(4, 10), slice(None, None, -1), Ellipsis))
print('Setting...')
f[0] = 1
f[5:10, (100)] = 2
f[...] = 100
print('Equivalently:')
f.__setitem__(0, 1)
f.__setitem__((slice(5, 10), 100), 2)
f.__setitem__(Ellipsis, 100)
Use Numpy Multidimensional Array Slicing Without Using the [slice,slice] Syntax?