re: Python for JavaScript Developers VIEW POST

FULL DISCUSSION
 

Correction for Lists section:

a_list[2, -2]

doesn't work.
It's same as:

index = (2, -2)  # a tuple
a_list[index]

which gives "TypeError: list indices must be integers or slices, not tuple".

Some custom list-like objects, notably NumPy arrays, do support extracting multiple values for multiple indexes. (Except they do this given a list of indixes, as they already interpret tuples for multi-dimensional indexing.)
Anyway, it's not a builtin feature of the language.

code of conduct - report abuse