numpy - How do you use the ellipsis slicing syntax in Python? -


this came in hidden features of python, can't see documentation or examples explain how feature works.

you'd use in own class, since no builtin class makes use of it.

numpy uses it, stated in documentation. examples here.

in own class, you'd use this:

>>> class testellipsis(object): ...     def __getitem__(self, item): ...         if item ellipsis: ...             return "returning items" ...         else: ...             return "return %r items" % item ...  >>> x = testellipsis() >>> print x[2] return 2 items >>> print x[...] returning items 

of course, there python documentation, , language reference. aren't helpful.


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -