Zipping a dictionary whose values are lists

Arnaud Delobelle arnodel at gmail.com
Sat Apr 14 17:35:33 EDT 2012


On 13 April 2012 17:35, Kiuhnm <kiuhnm03.4t.yahoo.it at mail.python.org> 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



More information about the Python-list mailing list