[Python-Dev] Can we please have a better dict interpolation syntax?

Skip Montanaro skip at pobox.com
Thu Oct 23 09:55:22 EDT 2003


    Greg> I would *really* like to be able to write this as

    Greg>   "create index %{table}_lid1_idx on %{table}(%{lid1})" % params

    Greg> which I find to be much easier on the eyes.

What if lid1 is a float which you want to display with two digits past the
decimal point?

I think we've been around the block on this one a few times.  While %{foo}
might be a convenient shorthand for %(foo)s, I don't think it saves enough
space (one character) or stands out that much more ("{...}" instead of
"(...)s") to make the addition worthwhile.  In addition, you'd have to
retain the current construct in cases where something other than simple
string interpolation was required, in which case you also have the problem
of having two almost identical ways to do dictionary interpolation.

Skip



More information about the Python-Dev mailing list