Peter Otten wrote:
> Duncan Booth wrote:
>
>> Peter Otten <[email protected]> wrote:
>>
>>> With next(islice(...), None) I seem to have found a variant that beats
>>> both competitors.
>>>
>> It has different behaviour for n==0 but I'm sure that's easily fixed.
>
> "Different behaviour" being a euphemism for broken ;)
>
> def consume_islice(n, items):
> if n == 0:
> return
> next(islice(items, n-1, None), None)
Even better:
def consume_islice(n, items):
next(islice(items, n, n), None)
Peter
--
http://mail.python.org/mailman/listinfo/python-list