PEP 276 Simple Iterator for ints
tim.hochberg at ieee.org
Wed Nov 14 05:28:09 CET 2001
"William Tanksley" wrote :
> James_Althoff at i2.com wrote:
> > - It would be better to reuse the ellipsis literal syntax (...)
> > Response: Shares disadvantages of other proposals that require
> > changes to the syntax. Needs more design to determine how it
> > would handle the general case of start,stop,step,
> > open/closed/half-closed intervals, etc. Needs a PEP.
> The last sentance is the only one that matters here. However, I'm
> curious: what do you mean "reuse"? I've never seen an "ellipsis literal"
> in Python. Reading through the Python documentation, I see an ellipsis
> notation for extended slicing, but I'm in the dark as to what it means.
> (I can guess, but I'd rather see it in print.) I've never seen it in
> Python code, and the documentation doesn't seem to mention it.
As far as I know the ellipsis syntax is only currently used in NumPy. It's a
builtin, though -- you can see it just by typing Ellipsis at the prompt. You
could use it today if you wanted:
someObject[a, b, ..., c]
gets translated to:
someObject.__getitem__((a, b, Ellipsis, c))
So you can use it in your own class if you want. In particular, one could
int[1,3,...,53] act like range(1,53,2) if one wanted.
More information about the Python-list