Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> class TestEllipsis(object):
- ... def __getitem__(self, item):
- ... if item is Ellipsis:
- ... return "Returning all items"
- ... else:
- ... return "return %r items" % item
- ...
- >>> x = TestEllipsis()
- >>> print x[2]
- return 2 items
- >>> print x[...]
- Returning all items
- >>> from numpy import arange
- >>> a = arange(16).reshape(2,2,2,2)
- >>> a[..., 0].flatten()
- array([ 0, 2, 4, 6, 8, 10, 12, 14])
- >>> a[:,:,:,0].flatten()
- array([ 0, 2, 4, 6, 8, 10, 12, 14])
Add Comment
Please, Sign In to add comment