H
Henrik Faber
Hi group,
I have a question of which I'm unsure if the specification guarantees
it. With an arbitrary dictionaty d, are d.keys() and d.values()
guaraneed to be in the same order? I.e. what I mean is:
# For all dictionaries d:
assert({ list(d.keys()): list(d.values()) for i in range(len(d)) }
== d)
I'm curious if it's allowed because in a special case it would make for
a nice shortcut and clean code. I think however that the implementation
may chose not to have them in the same order necessarily -- then I'd
obviously avoid relying on it.
Best regards,
Joe
I have a question of which I'm unsure if the specification guarantees
it. With an arbitrary dictionaty d, are d.keys() and d.values()
guaraneed to be in the same order? I.e. what I mean is:
# For all dictionaries d:
assert({ list(d.keys()): list(d.values()) for i in range(len(d)) }
== d)
I'm curious if it's allowed because in a special case it would make for
a nice shortcut and clean code. I think however that the implementation
may chose not to have them in the same order necessarily -- then I'd
obviously avoid relying on it.
Best regards,
Joe