Peter Otten <[EMAIL PROTECTED]> wrote:
> Let's see if I understand the above: In C a call
>
> f(g(), g())
>
> may result in machine code equivalent to either
>
> x = g()
> y = g()
> f(x, y)
>
> or
>
> y = g()
> x = g()
> f(x, y)
>
> Is that it?
>
Yes, or changing one of the calls to h() an
Duncan Booth wrote:
> Peter Otten <[EMAIL PROTECTED]> wrote:
>> But still, to help my lack of fantasy -- what would a sane zip()
>> implementation look like that does not guarantee the above output?
>>
> Hypothetically?
>
> The code in zip which builds the result tuples looks (ignoring error
> h
Peter Otten <[EMAIL PROTECTED]> wrote:
> But still, to help my lack of fantasy -- what would a sane zip()
> implementation look like that does not guarantee the above output?
>
Hypothetically?
The code in zip which builds the result tuples looks (ignoring error
handling) like:
// inside a loop
Alan Isaac wrote:
> "Peter Otten" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>> I like
>>
>> >>> items = range(9)
>> >>> N = 3
>> >>> zip(*[iter(items)]*N)
>> [(0, 1, 2), (3, 4, 5), (6, 7, 8)]
>
> Except that it is considered implementation dependent:
> http://mail.python.org/p
"Peter Otten" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I like
>
> >>> items = range(9)
> >>> N = 3
> >>> zip(*[iter(items)]*N)
> [(0, 1, 2), (3, 4, 5), (6, 7, 8)]
Except that it is considered implementation dependent:
http://mail.python.org/pipermail/python-list/2005-February
Hi!
r=iter(range(9))
print zip(r,r,r)
But, it's few like Peter...
--
Michel Claveau
--
http://mail.python.org/mailman/listinfo/python-list
On 2007-01-17, Will McGugan <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'd like a generator that takes a sequence and yields tuples containing
> n items of the sqeuence, but ignoring the 'odd' items. For example
>
> take_group(range(9), 3) -> (0,1,2) (3,4,5) (6,7,8)
>
> This is what I came up with..
>
>
On 17 Jan 2007 04:50:33 -0800, Will McGugan <[EMAIL PROTECTED]> wrote:
>
> Will McGugan wrote:
>
> > Hi,
> >
> > I'd like a generator that takes a sequence and yields tuples containing
> > n items of the sqeuence, but ignoring the 'odd' items. For example
>
> Forgot to add, for my purposes I will a
Will McGugan wrote:
> I'd like a generator that takes a sequence and yields tuples containing
> n items of the sqeuence, but ignoring the 'odd' items. For example
>
> take_group(range(9), 3) -> (0,1,2) (3,4,5) (6,7,8)
I like
>>> items = range(9)
>>> N = 3
>>> zip(*[iter(items)]*N)
[(0, 1, 2), (
Will McGugan wrote:
> Hi,
>
> I'd like a generator that takes a sequence and yields tuples containing
> n items of the sqeuence, but ignoring the 'odd' items. For example
Forgot to add, for my purposes I will always have a sequence with a
multiple of n items.
Will
--
http://mail.python.org/m
Hi,
I'd like a generator that takes a sequence and yields tuples containing
n items of the sqeuence, but ignoring the 'odd' items. For example
take_group(range(9), 3) -> (0,1,2) (3,4,5) (6,7,8)
This is what I came up with..
def take_group(gen, count):
i=iter(gen)
while True:
11 matches
Mail list logo