In <[EMAIL PROTECTED]> Terry Reedy <[EMAIL PROTECTED]> writes:


>kj wrote:

>> Is there a special pythonic idiom for iterating over a list (or
>> tuple) two elements at a time?
>> 
>> I mean, other than
>> 
>> for i in range(0, len(a), 2):
>>     frobnicate(a[i], a[i+1])

>There have been requests to add a grouper function to itertools, but its 
>author has resisted because there are at least three things one might do 
>with the short remainder group left over when the group size does not 
>evenly divide the sequence size: drop it, return it, or fill it to the 
>requested groupsize with a dummy value and then return it.

Why not make this choice a third argument to the grouper function?

Kynn

-- 
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to