Andre Engels wrote:
On Thu, Mar 5, 2009 at 6:01 PM, Tino Wildenhain t...@wildenhain.de wrote:
Still I'd like to see an application where this really matters (that
keys() and values() match in order)
I think there are many such applications, but also that in each of
those cases it's a
Hi,
psykeedelik wrote:
On Mar 5, 6:01 pm, Tino Wildenhain t...@wildenhain.de wrote:
Piet van Oostrum wrote:
Andre Engels andreeng...@gmail.com (AE) wrote:
AE On Wed, Mar 4, 2009 at 11:02 AM, lone_eagle icym...@gmail.com wrote:
Can someone suggest a easy method to do the inverse of
Andre Engels wrote:
On Thu, Mar 5, 2009 at 7:46 PM, Andre Engels andreeng...@gmail.com wrote:
If the dict = {key1: val1, key2: val2, ...}, you can do:
for key in dict:
plot(key,dictionary[key])
Of course I meant:
for key in dict:
plot(key,dict[key])
Which would be the verbose
Piet van Oostrum wrote:
Andre Engels andreeng...@gmail.com (AE) wrote:
AE On Wed, Mar 4, 2009 at 11:02 AM, lone_eagle icym...@gmail.com wrote:
Can someone suggest a easy method to do the inverse of dict(zip(x,y))
to get two lists x and y?
So, if x and y are two lists, it is easier to make a
On Thu, Mar 5, 2009 at 6:01 PM, Tino Wildenhain t...@wildenhain.de wrote:
Still I'd like to see an application where this really matters (that
keys() and values() match in order)
I think there are many such applications, but also that in each of
those cases it's a mis-programming of something
On Mar 5, 6:01 pm, Tino Wildenhain t...@wildenhain.de wrote:
Piet van Oostrum wrote:
Andre Engels andreeng...@gmail.com (AE) wrote:
AE On Wed, Mar 4, 2009 at 11:02 AM, lone_eagle icym...@gmail.com wrote:
Can someone suggest a easy method to do the inverse of dict(zip(x,y))
to get two
On Thu, Mar 5, 2009 at 7:07 PM, psykeedelik icym...@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
On Thu, Mar 5, 2009 at 7:46 PM, Andre Engels andreeng...@gmail.com wrote:
If the dict = {key1: val1, key2: val2, ...}, you can do:
for key in dict:
plot(key,dictionary[key])
Of course I meant:
for key in dict:
plot(key,dict[key])
--
André Engels, andreeng...@gmail.com
--
On Mar 5, 9:01 am, Tino Wildenhain t...@wildenhain.de wrote:
Piet van Oostrum wrote:
Andre Engels andreeng...@gmail.com (AE) wrote:
AE On Wed, Mar 4, 2009 at 11:02 AM, lone_eagle icym...@gmail.com wrote:
Can someone suggest a easy method to do the inverse of dict(zip(x,y))
to get two
Can someone suggest a easy method to do the inverse of dict(zip(x,y))
to get two lists x and y?
So, if x and y are two lists, it is easier to make a dictionary using
d = dict(zip(x,y)), but if I have d of the form, d = {x1:y1,
x2:y2, ...}, what is there any trick to get lists x = [x1, x2, ...]
lone_eagle icym...@gmail.com writes:
So, if x and y are two lists, it is easier to make a dictionary using
d = dict(zip(x,y)), but if I have d of the form, d = {x1:y1,
x2:y2, ...}, what is there any trick to get lists x = [x1, x2, ...]
and y = [y1, y2, ...]
This may be a bit of a mind bender,
On Wed, Mar 4, 2009 at 11:02 AM, lone_eagle icym...@gmail.com wrote:
Can someone suggest a easy method to do the inverse of dict(zip(x,y))
to get two lists x and y?
So, if x and y are two lists, it is easier to make a dictionary using
d = dict(zip(x,y)), but if I have d of the form, d =
On Mar 4, 11:06 am, Paul Rubin http://phr...@nospam.invalid wrote:
lone_eagle icym...@gmail.com writes:
So, if x and y are two lists, it is easier to make a dictionary using
d = dict(zip(x,y)), but if I have d of the form, d = {x1:y1,
x2:y2, ...}, what is there any trick to get lists x =
Andreas Tawn wrote:
Can someone suggest a easy method to do the inverse of dict(zip(x,y))
to get two lists x and y?
So, if x and y are two lists, it is easier to make a dictionary using
d = dict(zip(x,y)), but if I have d of the form, d = {x1:y1,
x2:y2, ...}, what is there any trick to get lists
lone_eagle wrote:
Hi all,
This might be trivial ...
Can someone suggest a easy method to do the inverse of dict(zip(x,y))
to get two lists x and y?
So, if x and y are two lists, it is easier to make a dictionary using
d = dict(zip(x,y)), but if I have d of the form, d = {x1:y1,
x2:y2, ...},
psykeedelik icym...@gmail.com writes:
Keys and values are listed in an arbitrary order which is non-
random, varies across Python implementations, and depends on the
dictionary’s history of insertions and deletions.
I hope it does not mean that the key-value mapping is not
guaranteed,
Andre Engels wrote:
y = d.values() might also work, but I am not sure whether d.keys() and
d.values() are guaranteed to use the same order.
If they were called immediately after each other I think they should,
but better not rely on it.
--
http://mail.python.org/mailman/listinfo/python-list
Lie Ryan wrote:
Andre Engels wrote:
y = d.values() might also work, but I am not sure whether d.keys() and
d.values() are guaranteed to use the same order.
If they were called immediately after each other I think they should,
but better not rely on it.
otoh, I could not think of any use
So, if x and y are two lists, it is easier to make a dictionary using
d = dict(zip(x,y)), but if I have d of the form, d = {x1:y1,
x2:y2, ...}, what is there any trick to get lists x = [x1, x2, ...]
and y = [y1, y2, ...]
Cheers,
Chaitanya.
x = d.keys()
y = d.values()
But be aware that you
Andre Engels andreeng...@gmail.com (AE) wrote:
AE On Wed, Mar 4, 2009 at 11:02 AM, lone_eagle icym...@gmail.com wrote:
Can someone suggest a easy method to do the inverse of dict(zip(x,y))
to get two lists x and y?
So, if x and y are two lists, it is easier to make a dictionary using
d =
Having a look at python documentation I found:
zip() in conjunction with the * operator can be used to unzip a list:
x = [1, 2, 3]
y = [4, 5, 6]
zipped = zip(x, y)
zipped
[(1, 4), (2, 5), (3, 6)]
x2, y2 = zip(*zipped)
x == x2, y == y2
True
So,
x2, y2 = zip(*d.items())
should fix your
Lorenzo wrote:
zip() in conjunction with the * operator can be used to unzip a list:
That's because zip is the inverse operation of zip. I remember someone
saying that zip's typical name is transpose (like in matrix transpose).
a == zip(*zip(*a))
nitpick * in argument unpacking is not
On Mar 4, 5:33 am, Lie Ryan lie.1...@gmail.com wrote:
Andre Engels wrote:
y = d.values() might also work, but I am not sure whether d.keys() and
d.values() are guaranteed to use the same order.
If they were called immediately after each other I think they should,
but better not rely on it.
On Mar 4, 5:33 am, Lie Ryan lie.1...@gmail.com wrote:
Andre Engels wrote:
y = d.values() might also work, but I am not sure whether d.keys() and
d.values() are guaranteed to use the same order.
If they were called immediately after each other I think they should,
but better not rely on it.
Andre Engels andreengels at gmail.com writes:
y = d.values() might also work, but I am not sure whether d.keys() and
d.values() are guaranteed to use the same order.
They are for the builtin dictionary type, but that requirement does not extend
to any other mapping type. (It's not a requirement
On Wed, 04 Mar 2009 08:00:14 -0800, Paul McGuire wrote:
On Mar 4, 5:33 am, Lie Ryan lie.1...@gmail.com wrote:
Andre Engels wrote:
y = d.values() might also work, but I am not sure whether d.keys()
and d.values() are guaranteed to use the same order.
If they were called immediately after
Steven D'Aprano ste...@remove.this.cybersource.com.au writes:
Sure, but if you want two lists, as the OP asked for, then you have to
iterate over it twice either way:
# method 1:
keys = dict.keys()
values = dict.values()
# method 2:
keys, values = zip(*dict.items())
First you
27 matches
Mail list logo