[Python-checkins] r54464 - python/branches/release25-maint/Doc/lib/libitertools.tex

Thomas Wouters thomas at python.org
Wed Mar 21 15:50:27 CET 2007


On 3/20/07, raymond.hettinger <python-checkins at python.org> wrote:
>
> Author: raymond.hettinger
> Date: Tue Mar 20 22:12:23 2007
> New Revision: 54464
>
> Modified:
>    python/branches/release25-maint/Doc/lib/libitertools.tex
> Log:
> Add new example
>
> Modified: python/branches/release25-maint/Doc/lib/libitertools.tex
>
> ==============================================================================
> --- python/branches/release25-maint/Doc/lib/libitertools.tex    (original)
> +++ python/branches/release25-maint/Doc/lib/libitertools.tex    Tue Mar 20
> 22:12:23 2007
> @@ -539,5 +539,8 @@
>      "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))


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 :)

-- 
Thomas Wouters <thomas at python.org>

Hi! I'm a .signature virus! copy me into your .signature file to help me
spread!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-checkins/attachments/20070321/b3c80862/attachment.htm 


More information about the Python-checkins mailing list