[Python-il] elegant non contiguous slice

Avishalom Shalit avishalom at gmail.com
Thu Dec 30 00:11:01 IST 2010


Is there a way to elegantly take the (e.g. ) 2nd 7th and 10th element in a list

i.e.
more elegant than
[arr[x] for x in [1,6,9] ]

along the lines of
arr[1,6,9]

not a big issue, but i am curious

-- vish


More information about the Python-il mailing list