Cleaner idiom for text processing?
Michele Simionato
michele.simionato at poste.it
Thu May 27 04:31:49 EDT 2004
Peter Otten <__peter__ at web.de> wrote in message news:<c91got$vpi$00$1 at news.t-online.com>...
> Yet another way to create the dictionary:
>
> >>> import itertools
> >>> nv = iter("foo 1 bar 2 baz 3\n".split())
> >>> dict(itertools.izip(nv, nv))
> {'baz': '3', 'foo': '1', 'bar': '2'}
> >>>
>
> Peter
Cool! This should go in the Cookbook, in the shortcuts section.
Michele Simionato
More information about the Python-list
mailing list