Duncan Booth wrote: > Peter Otten <__pete...@web.de> 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) Peter -- http://mail.python.org/mailman/listinfo/python-list