string formatting with mapping & '*'... is this a bug?
aleaxit at yahoo.com
Fri Sep 10 00:20:24 CEST 2004
Diez B. Roggisch <deetsNOSPAM at web.de> wrote:
> map2 = dict(map.items() + [(str(i), v) for i, v in enumerate(vals)])
An equivalent ctor call that's slightly better, IMHO:
map2 = dict([ (str(i),v) for i,v in enumerate(vals) ], **map)
Don't ignore the power of dict's keyword arguments...
> Not perfect, but IMHO better than your eval-based solution.
I agree, mine is just a tiny improvement on your post, IMHO.
More information about the Python-list