Steven D'Aprano wrote:

> Are there better or more Pythonic alternatives to this obvious C-like
> idiom?
> 
> for i in range(1, len(alist)):
>     x = alist[i]

For small start values you can use itertools.islice(), e. g:

for x in islice(alist, 1, None):
    # use x

You'd have to time at what point the C-like idiom (which I would have no
qualms using throughout) becomes faster.

Peter

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to