Arnaud Delobelle wrote:
Em 01-02-2012 01:39, Paulo da Silva escreveu:
What is the best way to iterate thru a huge list having the 1st element
a different process? I.e.:
Nobody mentioned itertools.islice, which can be handy, especially if
you weren't interested in the first element of the
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
On 1 February 2012 08:11, Peter Otten __pete...@web.de wrote:
Arnaud Delobelle wrote:
The example should be
from itertools import islice:
for el in islice(mylist, 1, None):
process2(el)
Oops!
--
Arnaud
--
http://mail.python.org/mailman/listinfo/python-list
Paul Rubin, 01.02.2012 10:25:
Paulo da Silva 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
Em 01-02-2012 04:55, Cameron Simpson escreveu:
On 01Feb2012 03:34, Paulo da Silva p_s_d_a_s_i_l_...@netcabo.pt wrote:
| BTW, iter seems faster than iterating thru mylist[1:]!
I would hope the difference can be attributed to the cost of copying
mylist[1:].
I don't think so. I tried several
On Thu, 02 Feb 2012 07:23:04 +, Paulo da Silva wrote:
Em 01-02-2012 04:55, Cameron Simpson escreveu:
On 01Feb2012 03:34, Paulo da Silva p_s_d_a_s_i_l_...@netcabo.pt
wrote:
| BTW, iter seems faster than iterating thru mylist[1:]!
I would hope the difference can be attributed to the
On 01Feb2012 01:39, Paulo da Silva p_s_d_a_s_i_l_...@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?
On 1 February 2012 12:39, Paulo da Silva p_s_d_a_s_i_l_...@netcabo.ptwrote:
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
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 =
Em 01-02-2012 01:39, Paulo da Silva escreveu:
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.
I think iter
Em 01-02-2012 03:16, Paulo da Silva escreveu:
Em 01-02-2012 01:39, Paulo da Silva escreveu:
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
On 01Feb2012 03:34, Paulo da Silva p_s_d_a_s_i_l_...@netcabo.pt wrote:
| Em 01-02-2012 03:16, Paulo da Silva escreveu:
| I think iter is nice for what I need.
| Thank you very much to all who responded.
|
| BTW, iter seems faster than iterating thru mylist[1:]!
I would hope the difference can
On 1 February 2012 03:16, Paulo da Silva p_s_d_a_s_i_l_...@netcabo.pt wrote:
Em 01-02-2012 01:39, Paulo da Silva escreveu:
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)
13 matches
Mail list logo