On 13 April 2012 17:35, Kiuhnm wrote:
> On 4/13/2012 17:58, Alexander Blinne wrote:
>>
>> zip(*[x[1] for x in sorted(d.items(), key=lambda y: y[0])])
>
> Or
> zip(*[d[k] for k in sorted(d.keys())])
.keys() is superfluous here:
zip(*(d[k] for k in sorted(d)))
--
Arnaud
--
http://mail.pyth
On 4/13/2012 17:58, Alexander Blinne wrote:
Am 12.04.2012 18:38, schrieb Kiuhnm:
Almost. Since d.values() = [[1,2], [1,2,3], [1,2,3,4]], you need to use
list(zip(*d.values()))
which is equivalent to
list(zip([1,2], [1,2,3], [1,2,3,4]))
Kiuhnm
While this accidently works in this case
Alexander Blinne wrote:
> zip(*[x[1] for x in sorted(d.items(), key=lambda y: y[0])])
Why not zip(*[x[1] for x in sorted(d.items())])?
--
http://mail.python.org/mailman/listinfo/python-list
Am 12.04.2012 18:38, schrieb Kiuhnm:
> Almost. Since d.values() = [[1,2], [1,2,3], [1,2,3,4]], you need to use
> list(zip(*d.values()))
> which is equivalent to
> list(zip([1,2], [1,2,3], [1,2,3,4]))
>
> Kiuhnm
While this accidently works in this case, let me remind you that
d.values() do
The below code should work:
zip(*d.values())
when you do *d.values() its going to return tuple of elements, which then
further be can be zipped to
achieve your desired result.
Regards,
Shambhu Rajak
Python Lover
-Original Message-
From: tkp...@gmail.com [mailto:tkp...@gmail.com]
Sent
On Thu, 12 Apr 2012 09:28:03 -0700 (PDT)
tkp...@gmail.com wrote:
> I using Python 3.2 and have a dictionary
> >>> d = {0:[1,2], 1:[1,2,3], 2:[1,2,3,4]}
>
> whose values are lists I would like to zip into a list of tuples. If
> I explicitly write:
> >>> list(zip([1,2], [1,2,3], [1,2,3,4])
> [(1, 1
tkp...@gmail.com wrote:
> I using Python 3.2 and have a dictionary
d = {0:[1,2], 1:[1,2,3], 2:[1,2,3,4]}
>
> whose values are lists I would like to zip into a list of tuples. If I
> explicitly write:
list(zip([1,2], [1,2,3], [1,2,3,4])
> [(1, 1, 1), (2, 2, 2)]
>
> I get exactly what I
On 4/12/2012 18:28, tkp...@gmail.com wrote:
I using Python 3.2 and have a dictionary
d = {0:[1,2], 1:[1,2,3], 2:[1,2,3,4]}
whose values are lists I would like to zip into a list of tuples. If I
explicitly write:
list(zip([1,2], [1,2,3], [1,2,3,4])
[(1, 1, 1), (2, 2, 2)]
I get exactly what
zip(*d.values())
On 12 April 2012 20:28, wrote:
> I using Python 3.2 and have a dictionary
d = {0:[1,2], 1:[1,2,3], 2:[1,2,3,4]}
>
> whose values are lists I would like to zip into a list of tuples. If I
> explicitly write:
list(zip([1,2], [1,2,3], [1,2,3,4])
> [(1, 1, 1), (2, 2, 2)]