In MicroPython, this seems to be a little different. I can see that I still get a slice object in place of the index, but that object doesn't seem to have any attributes or methods on it, and it's also not subscriptable. I tried the following code:
Code: Select all
>>> a = A()
>>> s = a[0:1]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'A' object is not subscriptable
>>> class A:
... def __getitem__(self, index):
... return index
...
...
...
>>> a = A()
>>> s = a[0:1]
>>> s
slice(0, 1, None)
>>> s.start
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'slice' object has no attribute 'start'
>>> s.indices(3)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'slice' object has no attribute 'indices'
>>> dir(s)
[]
>>> s[0]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'slice' object is not subscriptable
>>>