Paulo da Silva <p_s_d_a_s_i_l_...@netcabo.pt> writes:
> process1(mylist[0])
> for el in mylist[1:]:
>       process2(el)
>
> This way mylist is almost duplicated, isn't it?

I think it's cleanest to use itertools.islice to get the big sublist
(not tested):

   from itertools import islice

   process1 (mylist[0])
   for el in islice(mylist, 1, None):
       process2 (el)

The islice has a small, constant amount of storage overhead instead of
duplicating almost the whole list.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to