[Python-ideas] List indexing multiple elements
rymg19 at gmail.com
Mon Feb 20 15:54:34 EST 2017
Apologies if this has already been covered!
Right now, if you want to get multiple elements in a list, you have to do:
elements = [mylist[a], mylist[b]]
My proposal is two-folded:
- 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))`).
- Add support for indexing via tuples in list.__getitem__.
list.__getitem__(tuple) would roughly be equivalent to
The first part is solely so that slices would be allowed in the syntax, but
if you guys don't like the idea, the second part still stands.
Thoughts? *ducks from flying tomatoes*
Yoko Shimomura > ryo (supercell/EGOIST) > Hiroyuki Sawano >> everyone else
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas