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

Oren Tirosh oren-py-d at hishome.net
Fri Oct 24 14:48:50 EDT 2003
On Thu, Oct 23, 2003 at 02:36:41PM +1300, Greg Ewing wrote:
> I have just had the experience of writing a bunch
> of expressions of the form
> 
>   "create index %(table)s_lid1_idx on %(table)s(%(lid1)s)" % params
> 
> and found myself getting quite confused by all the parentheses
> and "s" suffixes. I would *really* like to be able to write
> this as
> 
>   "create index %{table}_lid1_idx on %{table}(%{lid1})" % params
> 
> which I find to be much easier on the eyes.

A while ago I proposed the following syntax for embedded expressions in 
strings, parsed at compile-time:
     "create index \{table}_lid1_idx on \{table}(\{lid1})"

And the equivalent runtime parsed version:
    r"create index \{table}_lid1_idx on \{table}(\{lid1})".cook(params)


testing-the-water-to-see-if-it's-PEP-time-ly yours,

   Oren




More information about the Python-Dev mailing list