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

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

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -