On 2/13/2013 2:00 PM, stephenw...@gmail.com wrote:
Hello,
Would it be feasible to modify the Python grammar to allow ':' to generate
slice objects everywhere rather than just indexers and top-level tuples of
indexers?
Right now in Py2.7, Py3.3:
"obj[:,2]" yields "obj[slice(None),2]"
but
"obj[(:,1),2]" is an error, instead of "obj[(slice(None), 1), 2]"
Also, more generally, you could imagine this working in (almost?) any
expression without ambiguity:
"a = (1:2)" could yield "a = slice(1,2)"
I believe the idea of slice literals has been rejected.
See motivating discussion for this at:
https://github.com/pydata/pandas/issues/2866
There might not be very many use cases for this currently outside of pandas,
but apparently the grammar was already modified to allow '...' outside indexers
and there's probably even fewer valid use cases for that:
"e = ..." yields "e = Ellipsis"
One dubious move does not justify another.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list