diff options
author | Raymond Hettinger <python@rcn.com> | 2007-03-20 21:12:23 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2007-03-20 21:12:23 (GMT) |
commit | 42f4cfa9b6612206258a0735f97c863cd14e2d03 (patch) | |
tree | 26d1de279d301b167ed3f25d61dc11561d9db3e9 /Doc | |
parent | c77f6c6ea4670bec31213023384ba6b051a09b44 (diff) | |
download | cpython-42f4cfa9b6612206258a0735f97c863cd14e2d03.zip cpython-42f4cfa9b6612206258a0735f97c863cd14e2d03.tar.gz cpython-42f4cfa9b6612206258a0735f97c863cd14e2d03.tar.bz2 |
Add new example
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/lib/libitertools.tex | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Doc/lib/libitertools.tex b/Doc/lib/libitertools.tex index 59fbd98..f39cde6 100644 --- a/Doc/lib/libitertools.tex +++ b/Doc/lib/libitertools.tex @@ -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} |