<br><br><div><span class="gmail_quote">On 3/20/07, <b class="gmail_sendername">raymond.hettinger</b> &lt;<a href="mailto:python-checkins@python.org">python-checkins@python.org</a>&gt; 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>&nbsp;&nbsp; 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&nbsp;&nbsp;&nbsp;&nbsp;(original)<br>+++ python/branches/release25-maint/Doc/lib/libitertools.tex&nbsp;&nbsp;&nbsp;&nbsp;Tue Mar 20 22:12:23 2007
<br>@@ -539,5 +539,8 @@<br>&nbsp;&nbsp;&nbsp;&nbsp; &quot;grouper(3, &#39;abcdefg&#39;, &#39;x&#39;) --&gt; (&#39;a&#39;,&#39;b&#39;,&#39;c&#39;), (&#39;d&#39;,&#39;e&#39;,&#39;f&#39;), (&#39;g&#39;,&#39;x&#39;,&#39;x&#39;)&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp; return izip(*[chain(iterable, repeat(padvalue, n-1))]*n)
<br><br>+def reverse_map(d):<br>+&nbsp;&nbsp;&nbsp;&nbsp;&quot;Return a new dict with swapped keys and values&quot;<br>+&nbsp;&nbsp;&nbsp;&nbsp;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&#39;t as readable without it :)
<br></div></div><br>-- <br>Thomas Wouters &lt;<a href="mailto:thomas@python.org">thomas@python.org</a>&gt;<br><br>Hi! I&#39;m a .signature virus! copy me into your .signature file to help me spread!