[issue24379] slice.literal notation

Tal Einat report at bugs.python.org
Tue Jun 9 21:17:04 CEST 2015


Tal Einat added the comment:

(see https://mail.python.org/mailman/listinfo/python-ideas)

But for x = [1,2,3,4], how will x[y] work for all of the following values of y?

y = slice.literal[0]
y = slice.literal[1:2]
y = slice.literal[0:1, ..., 3]

NumPy's s_ "magic object" is a factory, returning objects of different types depending on the given input. If you want an actual slice.literal class, then you'll have to supply a way to convert it into an object usable for indexing/slicing, e.g.:

y = slice.literal[0:1]
[1,2,3,4][y.as_indexer]

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24379>
_______________________________________


More information about the Python-bugs-list mailing list