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/025645.html below:

PEP 292, Simpler String Substitutions

[Python-Dev] Re: PEP 292, Simpler String SubstitutionsGuido van Rossum guido@python.org
Wed, 19 Jun 2002 21:06:27 -0400
> As Barry noted, this isn't as powerful as PEP 215 (er, was that the
> right number?  The earlier $interpolation one, anyway) because it
> doesn't allow arbitrary expressions.

That's intentional.  Trying to put an expression parser in the
interpolation code quickly leads to insanity.

> I'd imagine a common use case
> would be to shortcut an expression without binding it to a local
> variable,
> 
>   "The length is ${length}".sub(length = len(someString))
> 
> In this case it would be handy to use the default environment overridden
> by the new bindings, so you could do
>   
>   "The length of ${someString} is ${length}".sub(length =
>     len(someString))
> 
> But that could get messy real fast.  The idiom could be
> 
>   "The length of ${someString} is ${length}".sub(someString =
>     someString, length = len(someString))
> 
> But that's ugly.

I think you're simply trying to do too much in one line.  Simple is
better than complex.

--Guido van Rossum (home page: http://www.python.org/~guido/)




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