Iterate from 2nd element of a huge list
Cameron Simpson
cs at zip.com.au
Tue Jan 31 21:02:59 EST 2012
On 01Feb2012 01:39, Paulo da Silva <p_s_d_a_s_i_l_v_a at netcabo.pt> wrote:
| 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?
Yep.
What about (untested):
process1(mylist[0])
for i in xrange(1,len(mylist)):
process2(mylist[i])
Cheers,
--
Cameron Simpson <cs at zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/
The truth is, I will not give myself the trouble to write sense long, for I
would as soon please fools as wise men; because fools are more numerous, and
every prudent man will go with the majority. - Hugh Henry Brackenridge
More information about the Python-list
mailing list