[Python-ideas] extensible template strings

Eric V. Smith eric at trueblade.com
Thu Aug 20 02:15:05 CEST 2015


On 8/19/2015 7:43 PM, Guido van Rossum wrote:
> How important is it really to *hide* the fact that this involves a
> function call?

The only reason PEPs 498 and 501, and by extension Yuri's proposal, have
any difference over a function call is the ability to evaluate the
embedded expressions in the local context, before the function is
called. I agree that if it were just about hiding a function call, it
wouldn't be interesting at all.

But just as:
f'My name is {name}'

is arguably an improvement over:
'My name is {0}'.format(name)

So too would:
sql'select {columns} from {table}'

be easier to read than:
sql.run('select {} from {}', columns, table)

Still, I'm -0 on the template string idea.

Eric.


More information about the Python-ideas mailing list