On Wed, 23 Nov 2005 13:23:21 +0100, "Fredrik Lundh" <[EMAIL PROTECTED]> wrote:
>Bengt Richter wrote:
>
>> Are you thinking of something like lines from a file, where there might be
>> chunky buffering? ISTM that wouldn't matter if the same next method was
>> called.
>> Here we have multiple refer
Fredrik Lundh wrote:
> Bengt Richter wrote:
>
>> Are you thinking of something like lines from a file, where there might
>> be chunky buffering? ISTM that wouldn't matter if the same next method
>> was called. Here we have multiple references to the same iterator. Isn't
>> e.g. buiding a plain tu
Bengt Richter wrote:
> >it's not only the order that matters, but also the number of items
> >read from the source iterators on each iteration.
> >
> Not sure I understand.
>
> Are you thinking of something like lines from a file, where there might be
> chunky buffering? ISTM that wouldn't matter
On 22/11/05, Bengt Richter <[EMAIL PROTECTED]> wrote:
> That would be a counter-intuitive thing to do. Most things go left->right
> in order as the default assumption.
+1
--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
--
http://mail.python.org/mailman/listinfo/p
Bengt Richter wrote:
> Are you thinking of something like lines from a file, where there might be
> chunky buffering? ISTM that wouldn't matter if the same next method was
> called.
> Here we have multiple references to the same iterator. Isn't e.g. buiding
> a plain tuple defined with evaluation
On Wed, 23 Nov 2005 09:54:46 +0100, "Fredrik Lundh" <[EMAIL PROTECTED]> wrote:
>Bengt Richter wrote:
>
>> >Though it looks nice, it's an implementation dependant solution. What if
>> >someone changes zip to fetch the second item first?
>>
>> That would be a counter-intuitive thing to do. Most thin
Bengt Richter wrote:
> On Tue, 22 Nov 2005 13:26:45 +0100, "Fredrik Lundh"
> <[EMAIL PROTECTED]> wrote:
>>Duncan Booth wrote:
>>
>>> >>> it = iter(aList)
>>> >>> zip(it, it)
>>> [('a', 1), ('b', 2), ('c', 3)]
>>
>>is "relying on undefined behaviour" perhaps the new black ?
> Is it really undefin
[EMAIL PROTECTED] wrote:
> Personally, I would like to see it as [('a',1,'b',2), ('c',3,
> None,None)], as a list of tuple of equal length is easier to be dealt
> with.
>
> i = iter(aList)
> zip(i,chain(i,repeat(None)),
> chain(i,repeat(None)),chain(i,repeat(None)))
Here's some more:
>>> it =
Bengt Richter wrote:
> >Though it looks nice, it's an implementation dependant solution. What if
> >someone changes zip to fetch the second item first?
>
> That would be a counter-intuitive thing to do. Most things go left->right
> in order as the default assumption.
it's not only the order that
Bengt Richter wrote:
> On 22 Nov 2005 16:32:25 -0800, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
> >
> >Bengt Richter wrote:
> >> On 22 Nov 2005 07:42:31 -0800, "George Sakkis" <[EMAIL PROTECTED]> wrote:
> >>
> >> >"Laurent Rahuel" wrote:
> >> >
> >> >> Hi,
> >> >>
> >> >> newList = zip(aLis
On 22 Nov 2005 16:32:25 -0800, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
>Bengt Richter wrote:
>> On 22 Nov 2005 07:42:31 -0800, "George Sakkis" <[EMAIL PROTECTED]> wrote:
>>
>> >"Laurent Rahuel" wrote:
>> >
>> >> Hi,
>> >>
>> >> newList = zip(aList[::2], aList[1::2])
>> >> newList
>> >> [(
Bengt Richter wrote:
> On 22 Nov 2005 07:42:31 -0800, "George Sakkis" <[EMAIL PROTECTED]> wrote:
>
> >"Laurent Rahuel" wrote:
> >
> >> Hi,
> >>
> >> newList = zip(aList[::2], aList[1::2])
> >> newList
> >> [('a', 1), ('b', 2), ('c', 3)]
> >>
> >> Regards,
> >>
> >> Laurent
> >
> >Or if aList can g
Bengt Richter wrote:
> On Tue, 22 Nov 2005 13:37:06 +0100, =?ISO-8859-1?Q?Andr=E9?= Malo <[EMAIL
> PROTECTED]> wrote:
>
> >* Duncan Booth <[EMAIL PROTECTED]> wrote:
> >
> >> metiu uitem wrote:
> >>
> >> > Say you have a flat list:
> >> > ['a', 1, 'b', 2, 'c', 3]
> >> >
> >> > How do you efficient
On 22 Nov 2005 07:42:31 -0800, "George Sakkis" <[EMAIL PROTECTED]> wrote:
>"Laurent Rahuel" wrote:
>
>> Hi,
>>
>> newList = zip(aList[::2], aList[1::2])
>> newList
>> [('a', 1), ('b', 2), ('c', 3)]
>>
>> Regards,
>>
>> Laurent
>
>Or if aList can get very large and/or the conversion has to be
>perf
On Tue, 22 Nov 2005 20:12:52 GMT in comp.lang.python, [EMAIL PROTECTED]
(Bengt Richter) wrote:
>On Tue, 22 Nov 2005 13:26:45 +0100, "Fredrik Lundh" <[EMAIL PROTECTED]> wrote:
>
>>Duncan Booth wrote:
>>
>>> That's funny, I thought your subject line said 'list of tuples'. I'll
>>> answer the questio
On Tue, 22 Nov 2005 14:28:56 GMT, "David Isaac" <[EMAIL PROTECTED]> wrote:
>
>"Duncan Booth" <[EMAIL PROTECTED]> wrote in message
>news:[EMAIL PROTECTED]
>> >>> aList = ['a', 1, 'b', 2, 'c', 3]
>> >>> it = iter(aList)
>> >>> zip(it, it)
>> [('a', 1), ('b', 2), ('c', 3)]
>
>That behavior is current
On Tue, 22 Nov 2005 13:37:06 +0100, =?ISO-8859-1?Q?Andr=E9?= Malo <[EMAIL
PROTECTED]> wrote:
>* Duncan Booth <[EMAIL PROTECTED]> wrote:
>
>> metiu uitem wrote:
>>
>> > Say you have a flat list:
>> > ['a', 1, 'b', 2, 'c', 3]
>> >
>> > How do you efficiently get
>> > [['a', 1], ['b', 2], ['c', 3]
On Tue, 22 Nov 2005 13:26:45 +0100, "Fredrik Lundh" <[EMAIL PROTECTED]> wrote:
>Duncan Booth wrote:
>
>> That's funny, I thought your subject line said 'list of tuples'. I'll
>> answer the question in the subject rather than the question in the body:
>>
>> >>> aList = ['a', 1, 'b', 2, 'c', 3]
>> >
On 22 Nov 2005 11:11:23 GMT, Duncan Booth <[EMAIL PROTECTED]> wrote:
>metiu uitem wrote:
>
>> Say you have a flat list:
>> ['a', 1, 'b', 2, 'c', 3]
>>
>> How do you efficiently get
>> [['a', 1], ['b', 2], ['c', 3]]
>
>That's funny, I thought your subject line said 'list of tuples'. I'll
>answer
"Laurent Rahuel" wrote:
> Hi,
>
> newList = zip(aList[::2], aList[1::2])
> newList
> [('a', 1), ('b', 2), ('c', 3)]
>
> Regards,
>
> Laurent
Or if aList can get very large and/or the conversion has to be
performed many times:
from itertools import islice
newList = zip(islice(aList,0,None,2), isl
"Duncan Booth" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> >>> aList = ['a', 1, 'b', 2, 'c', 3]
> >>> it = iter(aList)
> >>> zip(it, it)
> [('a', 1), ('b', 2), ('c', 3)]
That behavior is currently an accident.
http://sourceforge.net/tracker/?group_id=5470&atid=105470&func=detail
André Malo wrote:
> * Duncan Booth <[EMAIL PROTECTED]> wrote:
>
> > metiu uitem wrote:
> >
> > > Say you have a flat list:
> > > ['a', 1, 'b', 2, 'c', 3]
> > >
> > > How do you efficiently get
> > > [['a', 1], ['b', 2], ['c', 3]]
> >
> > That's funny, I thought your subject line said 'list of tupl
* Duncan Booth <[EMAIL PROTECTED]> wrote:
> metiu uitem wrote:
>
> > Say you have a flat list:
> > ['a', 1, 'b', 2, 'c', 3]
> >
> > How do you efficiently get
> > [['a', 1], ['b', 2], ['c', 3]]
>
> That's funny, I thought your subject line said 'list of tuples'. I'll
> answer the question in t
Duncan Booth wrote:
> That's funny, I thought your subject line said 'list of tuples'. I'll
> answer the question in the subject rather than the question in the body:
>
> >>> aList = ['a', 1, 'b', 2, 'c', 3]
> >>> it = iter(aList)
> >>> zip(it, it)
> [('a', 1), ('b', 2), ('c', 3)]
yesterday, we g
On Tue, 22 Nov 2005 11:11:23 +, Duncan Booth wrote:
aList = ['a', 1, 'b', 2, 'c', 3]
it = iter(aList)
zip(it, it)
> [('a', 1), ('b', 2), ('c', 3)]
I'm not sure if I should fall to my knees in admiration of a Cool Hack,
or recoil in horror at a Bogus Kludge :-)
The code looks l
Thanks for the answer... yes the example was wrong!
--
http://mail.python.org/mailman/listinfo/python-list
metiu uitem wrote:
> Say you have a flat list:
> ['a', 1, 'b', 2, 'c', 3]
>
> How do you efficiently get
> [['a', 1], ['b', 2], ['c', 3]]
>
> I was thinking of something along the lines of:
> for (key,number) in list:
> print key, number
>
> but it's not working...
>
> Thank you
Hi,
newLis
Duncan Booth wrote:
> metiu uitem wrote:
>
> > Say you have a flat list:
> > ['a', 1, 'b', 2, 'c', 3]
> >
> > How do you efficiently get
> > [['a', 1], ['b', 2], ['c', 3]]
>
> That's funny, I thought your subject line said 'list of tuples'. I'll
> answer the question in the subject rather than the
"metiu uitem" wrote:
> Say you have a flat list:
> ['a', 1, 'b', 2, 'c', 3]
>
> How do you efficiently get
> [['a', 1], ['b', 2], ['c', 3]]
simplest possible (works in all Python versions):
L = ['a', 1, 'b', 2, 'c', 3]
out = []
for i in range(0, len(L), 2):
out.append(L[i:i+
On Tue, 22 Nov 2005 02:57:14 -0800, metiu uitem wrote:
> Say you have a flat list:
> ['a', 1, 'b', 2, 'c', 3]
>
> How do you efficiently get
> [['a', 1], ['b', 2], ['c', 3]]
def split_and_combine(L):
newL = []
for i in range(len(L)//2):
newL.append( [L[2*i], L[2*i+1]] )
retur
metiu uitem wrote:
> Say you have a flat list:
> ['a', 1, 'b', 2, 'c', 3]
>
> How do you efficiently get
> [['a', 1], ['b', 2], ['c', 3]]
That's funny, I thought your subject line said 'list of tuples'. I'll
answer the question in the subject rather than the question in the body:
>>> aList = [
Say you have a flat list:
['a', 1, 'b', 2, 'c', 3]
How do you efficiently get
[['a', 1], ['b', 2], ['c', 3]]
I was thinking of something along the lines of:
for (key,number) in list:
print key, number
but it's not working...
Thank you
--
http://mail.python.org/mailman/listinfo/python-list
32 matches
Mail list logo