On 3/15/18 12:35 PM, Peter Otten wrote:
Ned Batchelder wrote:
On 3/15/18 9:57 AM, Vlastimil Brom wrote:
2018-03-15 12:54 GMT+01:00 Arkadiusz Bulski :
I have a custom class (a lazy list-like container) that needs to support
slicing. The __getitem__ checks if index is of slice type, and does a
Ned Batchelder wrote:
> On 3/15/18 9:57 AM, Vlastimil Brom wrote:
>> 2018-03-15 12:54 GMT+01:00 Arkadiusz Bulski :
>>> I have a custom class (a lazy list-like container) that needs to support
>>> slicing. The __getitem__ checks if index is of slice type, and does a
>>> list comprehension over indi
Found the answer on stack overflow. Some types on some runtimes (builtins
and on Python 2) use another method __getslice__ instead of __getitem__.
https://docs.python.org/2/reference/datamodel.html#object.__getslice__
czw., 15 mar 2018 o 12:54 użytkownik Arkadiusz Bulski
napisał:
> I have a cus
On 3/15/18 9:57 AM, Vlastimil Brom wrote:
2018-03-15 12:54 GMT+01:00 Arkadiusz Bulski :
I have a custom class (a lazy list-like container) that needs to support
slicing. The __getitem__ checks if index is of slice type, and does a list
comprehension over individual integer indexes. The code work
2018-03-15 12:54 GMT+01:00 Arkadiusz Bulski :
> I have a custom class (a lazy list-like container) that needs to support
> slicing. The __getitem__ checks if index is of slice type, and does a list
> comprehension over individual integer indexes. The code works fine on
> Python 3 but fails on 2.7,
I have a custom class (a lazy list-like container) that needs to support
slicing. The __getitem__ checks if index is of slice type, and does a list
comprehension over individual integer indexes. The code works fine on
Python 3 but fails on 2.7, both CPython and PyPy. The print inside
__getitem__ do