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
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
handling)
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() and compiling with
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:
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
--
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), (3, 4, 5), (6,
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 always have a
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..
def
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
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/307550.html
Alan
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:
11 matches
Mail list logo