<br><br><div><span class="gmail_quote">On 3/20/07, <b class="gmail_sendername">raymond.hettinger</b> <<a href="mailto:python-checkins@python.org">python-checkins@python.org</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Author: raymond.hettinger<br>Date: Tue Mar 20 22:12:23 2007<br>New Revision: 54464<br><br>Modified:<br> python/branches/release25-maint/Doc/lib/libitertools.tex<br>Log:<br>Add new example<br><br>Modified: python/branches/release25-maint/Doc/lib/libitertools.tex
<br>==============================================================================<br>--- python/branches/release25-maint/Doc/lib/libitertools.tex (original)<br>+++ python/branches/release25-maint/Doc/lib/libitertools.tex Tue Mar 20 22:12:23 2007
<br>@@ -539,5 +539,8 @@<br> "grouper(3, 'abcdefg', 'x') --> ('a','b','c'), ('d','e','f'), ('g','x','x')"<br> return izip(*[chain(iterable, repeat(padvalue, n-1))]*n)
<br><br>+def reverse_map(d):<br>+ "Return a new dict with swapped keys and values"<br>+ return dict(izip(d.itervalues(), d))</blockquote><div><br>Should we be advocating code that (rather implicitly) relies on a dict not changing ordering between calls (not to mention different calls)? (It strikes me as rather bad style, and fragile to boot, but the example isn't as readable without it :)
<br></div></div><br>-- <br>Thomas Wouters <<a href="mailto:thomas@python.org">thomas@python.org</a>><br><br>Hi! I'm a .signature virus! copy me into your .signature file to help me spread!