Apr-22-2019, 02:34 AM
I don't know exactly how Numpy does it. But you could do it for your own classes by overriding __getitem__(key) and __setitem__(key, value). Whatever is in the brackets gets passed to those methods as the key parameter. In the example you give, it's a tuple of two slices. But as far as I know, it could be anything. And you could do anything with it. You could have it be the string 'one to five' and write code that would interpret that as 1:5 and return the appropriate slice of whatever.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures