opposite of dict.items()
Peter Otten
__peter__ at web.de
Fri Aug 29 07:53:47 EDT 2003
Raymond Hettinger wrote:
> If you're using Py2.3, then the itertools way is a bit nicer:
>
>>>> dict(itertools.izip(range(3), "abc"))
> {0: 'a', 1: 'b', 2: 'c'}
>>> dict(izip(irange(3), "abc"))
{0: 'a', 1: 'b', 2: 'c'}
If I could use the above in Py2.4, it would be even nicer, namely:
- convert itertools to builtins
- add irange(), perhaps as an alias for xrange() like file/open
That would remove the slant towards the list prcessing functions and
encourage lazy people like me to always choose the best solution :-)
Peter
More information about the Python-list
mailing list