[Tutor] A question on getting binary data from the net

Tom Jenkins tjenkins@devis.com
12 Jul 2002 17:30:33 -0400


On Fri, 2002-07-12 at 17:20, Tim Peters wrote:
> [Danny Yoo, having too much fun <wink>]
[snip]
> 
> Something to note here too:
> 
>     for i in range(len(sequence)/2):
>         fours.append(sequence[i*2 : i*2 + 2])
> 
> Consider:
> 
>     for i in range(0, len(sequence), 2):
>         fours.append(sequence[i : i+2])
> 
> instead.  Before you know it, you won't have any code left at all <wink>.
> 

which (naturally for 2.+) leads to:
def clump_by_twos(sequence):
	return [sequence[i : i+2] for i in range(0, len(sequence), 2)]

i think the next step would required a neurological hookup <wink>

-- 

Tom Jenkins
Development InfoStructure
http://www.devis.com