Neal Becker wrote:
Is there any canned iterator adaptor that will
transform:
in = [1,2,3]
into:
out = [(1,2,3,4), (5,6,7,8),...]
That is, each time next() is called, a tuple of the next N items is
returned.
Here's one that abuses a for loop:
from itertools import islice
def grouper(
Chris Rebert wrote:
They really should just add grouper() to itertools rather than leaving
it as a recipe. People keep asking for it so often...
I've just added it to the issue tracker: http://bugs.python.org/issue6021
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, May 14, 2009 at 8:53 AM, Ned Deily wrote:
> In article ,
> Neal Becker wrote:
>> Is there any canned iterator adaptor that will
>>
>> transform:
>> in = [1,2,3]
>>
>> into:
>> out = [(1,2,3,4), (5,6,7,8),...]
>>
>> That is, each time next() is called, a tuple of the next N items is
>
In article ,
Neal Becker wrote:
> Is there any canned iterator adaptor that will
>
> transform:
> in = [1,2,3]
>
> into:
> out = [(1,2,3,4), (5,6,7,8),...]
>
> That is, each time next() is called, a tuple of the next N items is
> returned.
This topic was discussed here just a few days a
Neal Becker wrote:
Is there any canned iterator adaptor that will
transform:
in = [1,2,3]
into:
out = [(1,2,3,4), (5,6,7,8),...]
That is, each time next() is called, a tuple of the next N items is
returned.
An option, might be better since it handles infinite list correctly:
>>>
Neal Becker wrote:
> Is there any canned iterator adaptor that will
>
> transform:
> in = [1,2,3]
>
> into:
> out = [(1,2,3,4), (5,6,7,8),...]
>
> That is, each time next() is called, a tuple of the next N items is
> returned.
Depending on what you want to do with items that don't make a c
Neal Becker wrote:
> Is there any canned iterator adaptor that will
>
> transform:
> in = [1,2,3]
>
> into:
> out = [(1,2,3,4), (5,6,7,8),...]
>
> That is, each time next() is called, a tuple of the next N items is
> returned.
This is my best effort... not using itertools as my br
Neal Becker ha scritto:
Is there any canned iterator adaptor that will
transform:
in = [1,2,3]
into:
out = [(1,2,3,4), (5,6,7,8),...]
That is, each time next() is called, a tuple of the next N items is
returned.
http://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-
Is there any canned iterator adaptor that will
transform:
in = [1,2,3]
into:
out = [(1,2,3,4), (5,6,7,8),...]
That is, each time next() is called, a tuple of the next N items is
returned.
--
http://mail.python.org/mailman/listinfo/python-list
On Jul 19, 8:35 am, Matthew Wilson <[EMAIL PROTECTED]> wrote:
> I want to write a function that each time it gets called, it returns a
> random choice of 1 to 5 words from a list of words.
>
> I can write this easily using for loops and random.choice(wordlist) and
> random.randint(1, 5).
>
> But I
Matthew Wilson schrieb:
> I want to write a function that each time it gets called, it returns a
> random choice of 1 to 5 words from a list of words.
>
> I can write this easily using for loops and random.choice(wordlist) and
> random.randint(1, 5).
>
> But I want to know how to do this using it
Matthew Wilson wrote:
> I want to write a function that each time it gets called, it returns a
> random choice of 1 to 5 words from a list of words.
>
> I can write this easily using for loops and random.choice(wordlist) and
> random.randint(1, 5).
>
> But I want to know how to do this using iterto
Matthew Wilson a écrit :
> I want to write a function that each time it gets called, it returns a
> random choice of 1 to 5 words from a list of words.
>
> I can write this easily using for loops and random.choice(wordlist) and
> random.randint(1, 5).
>
> But I want to know how to do this using i
I want to write a function that each time it gets called, it returns a
random choice of 1 to 5 words from a list of words.
I can write this easily using for loops and random.choice(wordlist) and
random.randint(1, 5).
But I want to know how to do this using itertools, since I don't like
manually d
14 matches
Mail list logo