Inverse of dict(zip(x,y))

Andre Engels andreengels at gmail.com
Thu Mar 5 13:46:01 EST 2009


On Thu, Mar 5, 2009 at 7:07 PM, psykeedelik <icymist at gmail.com> wrote:

> I usually get properties that I compute, in a dictionary like property
> = [key1: val1, key2:val2, ...] and then I usually want to plot them in
> pylab, which AFAIK requires x and y as lists for the plot argument.
> Then I need to get the lists [key1, key2, ...] and [val1, val2, ...].
> And now I wonder if there a more efficient way doing what I described
> above!! ;)

If the dict = {key1: val1, key2: val2, ...}, you can do:

for key in dict:
    plot(key,dictionary[key])



-- 
André Engels, andreengels at gmail.com



More information about the Python-list mailing list