dict comprehension

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Fri Feb 1 05:09:55 EST 2008


Paul McGuire:
> Why not just
> D = dict(zip(keys,values))
> ??

Because this may require less memory:

from itertools import izip
D = dict(izip(keys, values))

:-)

Bear hugs,
bearophile



More information about the Python-list mailing list