string formatting with mapping & '*'... is this a bug?
Pierre Fortin
pfortin at pfortin.com
Thu Sep 9 18:37:05 EDT 2004
On Fri, 10 Sep 2004 00:20:24 +0200 Alex wrote:
> 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.
>
>
> Alex
Thanks for that; but it's not what I wanted... (see original post)
I was hoping to use the likes of: "%(key)*.*f" % map
however, unlike with the non-(key) formats, there appears to be no way to
specify a "*.*" size when a map is used...
Pierre
More information about the Python-list
mailing list