[Python-ideas] Briefer string format

Eric V. Smith eric at trueblade.com
Wed Jul 22 20:52:30 CEST 2015


On 07/20/2015 03:22 PM, Guido van Rossum wrote:
> Not sure what you mean by "implicit merging" -- if you mean literal
> concatenation (e.g. 'foo' "bar" == 'foobar') then I think it should be
> allowed, just like we support mixing quotes and r''.

Do we really want to support this? It complicates the implementation,
and I'm not sure of the value.

f'{foo}' 'bar' f'{baz}'
becomes something like:
format(foo) + 'bar' + format(baz)

You're not merging similar things, like you are with normal string
concatenation.

And merging f-strings:
f'{foo}' f'{bar'}
similarly just becomes concatenating the results of some function calls.

I guess it depends if you think of an f-string as a string, or an
expression (like the function calls it will become). I don't have a real
strong preference, but I'd like to get it ironed out logically before
doing a trial implementation.

Eric.




More information about the Python-ideas mailing list