[Edu-sig] Reversing dictionaries, closures, permutations etc.
Guido van Rossum
guido at python.org
Fri Jan 23 15:55:24 EST 2004
> How to reverse a dictionary? The dict class has no .reverse() method, which
> makes sense, as keys must be immutable so there's no guarantee the reverse
> is even valid (throwing an exception would be the way to go in this case).
I believe this is usually called "inverse". In Python, "reverse"
means reversing the order of the elements of a list,
e.g. lst.reverse() and in 2.4 the reversed() built-in.
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Edu-sig
mailing list