[issue32288] Inconsistent behavior with slice assignment?

Stefan Krah report at bugs.python.org
Tue Dec 12 07:46:19 EST 2017


Stefan Krah <stefan at bytereef.org> added the comment:

Python lists don't implement extended slices, try numpy arrays:

>>> import numpy as np
>>> x = array([[1,2,3], [4,5,6]])
>>> x[:, 2]
array([3, 6])
>>> 
>>> lst = [[1,2,3], [4,5,6]]
>>> lst[:, 2]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: list indices must be integers or slices, not tuple
>>> 

Was there any issue apart from the extended slices?

----------
nosy: +skrah

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32288>
_______________________________________


More information about the Python-bugs-list mailing list