Converting a flat list to a list of tuples
bokr at oz.net
Tue Nov 22 21:12:52 CET 2005
On Tue, 22 Nov 2005 13:26:45 +0100, "Fredrik Lundh" <fredrik at pythonware.com> 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]
>> >>> it = iter(aList)
>> >>> zip(it, it)
>> [('a', 1), ('b', 2), ('c', 3)]
>yesterday, we got locals()["_"]. and now this ?
I don't really think those are comparable.
>is "relying on undefined behaviour" perhaps the new black ?
Is it really undefined? If so, IMO it should be defined to
do what it apparently does.
>and people are impressed? it's like my old Z80 days, when
>some folks thought it was truly amazing that call(11) printed
>the raw contents of the entire memory to the screen...
You really don't think it was cool? Or could be well defined? ;-)
Hm, actually, something tells me I've seen some variation of this before,
but I can't think of the context off hand.
More information about the Python-list