This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author taleinat
Recipients Arfrever, llllllllll, mark.dickinson, rhettinger, serhiy.storchaka, steven.daprano, taleinat
Date 2015-06-09.16:00:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
(This should probably be discussed on the Python Ideas mailing list...)

I definitely like the idea of being able to construct slices etc. using "[]" syntax. I think this should be considered even if it is decided not to change the repr() of slices.

An important note here is that this is about more than slices:

$ python3
Python 3.4.2 (default, Feb 23 2015, 21:16:28)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> class A:
...     def __getitem__(self, *args):
...         print(repr(args))
>>> a = A()
>>> a[0]
>>> a[0:1]
(slice(0, 1, None),)
>>> a[0:1, ..., 1:2]
((slice(0, 1, None), Ellipsis, slice(1, 2, None)),)
>>> a[0:1, 2]
((slice(0, 1, None), 2),)

Indeed, Joe's suggested slice.literal supports all of this, but we can't just modify slice to handle all of these cases.

What I'm missing is a way to use such an object to actually index/slice something. The only way I can currently think of is using a.__getitem__(), but that's quite ugly IMO.
Date User Action Args
2015-06-09 16:00:03taleinatsetrecipients: + taleinat, rhettinger, mark.dickinson, Arfrever, steven.daprano, serhiy.storchaka, llllllllll
2015-06-09 16:00:03taleinatsetmessageid: <>
2015-06-09 16:00:03taleinatlinkissue24379 messages
2015-06-09 16:00:02taleinatcreate