On Mon, Feb 20, 2017 at 3:55 PM Ryan Gonzalez <rym...@gmail.com> wrote:

> - Right now, a[b,c] is already valid syntax, since it's just indexing a
> with the tuple (b, c). The proposal is to make this a specialization in the
> grammar, and also allow stuff like a[b:c, d:e] (like
> `a.__getitem__(slice(b, c), slice(d, e))`).
>

The syntax/grammar already permits slices to be used in this fashion:

Python 3.5.1 (v3.5.1:37a07cee5969, Dec  6 2015, 01:54:25) [MSC v.1900 64
bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> class Tester:
...   def __getitem__(self, *args):
...     print('object was indexed with these args:', args)
...
>>> obj = Tester()
>>> obj[3:5, 2:6, 7, -15:6:3]
object was indexed with these args: ((slice(3, 5, None), slice(2, 6, None),
7, slice(-15, 6, 3)),)
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to