Converting a flat list to a list of tuples
Fredrik Lundh
fredrik at pythonware.com
Tue Nov 22 07:26:45 EST 2005
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()["_[1]"]. and now this ?
is "relying on undefined behaviour" perhaps the new black ?
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...
</F>
More information about the Python-list
mailing list