Christopher Subich wrote:
> One caevat that I just noticed, though -- with the for-solution, you do 
> need to be careful about whether you're using a generator or list if you 
> do not set an explicit initial value (and instead use the first value of 
> 'sequence' as the start).  The difference is:
> _accum = g.next()
> for i in g: _accum = stuff(_accum,i)
> 
> versus
> _accum = g[0]
> for i in g[1:]: _accum = stuff(_accum,i)

If you want to be general for all iterables (list, generators, etc), you 
can write the code like:

itr = iter(g)
_accum = itr.next()
for i in itr:
     _accum = stuff(_accum, i)

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

Reply via email to