A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-June/025856.html below:

PEP 292, Simpler String Substitutions

[Python-Dev] Re: PEP 292, Simpler String Substitutions [Python-Dev] Re: PEP 292, Simpler String SubstitutionsPaul Prescod paul@prescod.net
Sun, 23 Jun 2002 12:36:34 -0700
Christian Tismer wrote:
> 
>...
> 
> Are you sure you got what I meant?
> I want to compile the variable references away at compile
> time, resulting in an ordinary format string.
> This string is wraped by the runtime _(), and
> the result is then interpolated with a dict.

How can that be?

Original expression:

_($"$foo")

Expands to:

_("%(x1)s"%{"x1": foo})

Standard Python order of operations will do the %-interpolation before
the method call! You say that it could instead be 

_("%(x1)s")%{"x1": foo}

But how would Python know to do that? "_" is just another function.
There is nothing magical about it. What if the function was instead
re.compile? In that case I would want to do the interpolation *before*
the compilation, not after!

Are you saying that the "_" function should be made special and
recognized by the compiler?

 Paul Prescod




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4