Iterate from 2nd element of a huge list

duncan smith buzzard at urubu.freeserve.co.uk
Tue Jan 31 21:31:33 EST 2012


On 01/02/12 01:39, Paulo da Silva wrote:
> Hi!
>
> What is the best way to iterate thru a huge list having the 1st element
> a different process? I.e.:
>
> process1(mylist[0])
> for el in mylist[1:]:
> 	process2(el)
>
> This way mylist is almost duplicated, isn't it?
>
> Thanks.

Maybe (untested),

it = iter(mylist)
process1(it.next())
for el in it:
     process2(el)


Duncan



More information about the Python-list mailing list