PEP 276 Simple Iterator for ints
Tim Hochberg
tim.hochberg at ieee.org
Tue Nov 13 23:28:09 EST 2001
"William Tanksley" wrote :
> James_Althoff at i2.com wrote:
[SNIP]
> > - 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
make
int[1,3,...,53] act like range(1,53,2) if one wanted.
-tim
More information about the Python-list
mailing list