Considering the following python session (3.6.1):
>>> from itertools import islice
>>> l = [i for i in range(10)]
>>> islice(l, 0, 1)
<itertools.islice object at 0x7f87c9293638>
>>> (lambda it: islice(it, 0, 1))(l)
<itertools.islice object at 0x7fe35ab40408>
Nothing is unexpected here. Now, with functools.partial
:
>>> from functools import partial
>>> partial(islice, 0, 1)(l)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Stop argument for islice() must be None or an integer: 0 <= x <= sys.maxsize.
partial
seems to interfer with islice
behavior in a very unexpected way.
What is the rationale behind this behavior ? Is this because islice do not handle keyword arguments, like str.split few versions ago ?