Add new example

This commit is contained in:
Raymond Hettinger 2007-03-20 21:12:23 +00:00
parent c77f6c6ea4
commit 42f4cfa9b6
1 changed files with 3 additions and 0 deletions

View File

@ -539,5 +539,8 @@ def grouper(n, iterable, padvalue=None):
"grouper(3, 'abcdefg', 'x') --> ('a','b','c'), ('d','e','f'), ('g','x','x')"
return izip(*[chain(iterable, repeat(padvalue, n-1))]*n)
def reverse_map(d):
"Return a new dict with swapped keys and values"
return dict(izip(d.itervalues(), d))
\end{verbatim}