[Python-ideas] Draft PEP on string interpolation

Eric V. Smith eric at trueblade.com
Mon Aug 24 02:37:57 CEST 2015


On 08/23/2015 08:23 PM, Terry Reedy wrote:
> On 8/23/2015 12:09 AM, Nick Coghlan wrote:
> 
>> Indeed, after working through this latest change, I ended up back
>> where I started from a syntactic perspective, with a proposal for
>> i(nterpolated)-strings rather than f(ormatted)-strings:
>> https://www.python.org/dev/peps/pep-0501/
> 
> As I understand the two proposals, the essential difference, glossing
> over surface syntax, is this.  Compiling f'<template>' would parse the
> template to an inaccessible structure of existing type (tuple?) and
> process it at runtime with unreplaceable code returning a string with
> interpolations.  Compiling i'<templat>', in your latest revision, would
> parse the template to an accessible structure of a new class.  The new
> class would have default code (in .__repr__) equivalent in result to the
> f code.  But additional methods or functions could return other strings
> (or even non-strings). (Being able to access the structure for debugging
> purposes might be helpful.) Is this basically it?
> 

I think so. I just posted a longer version of this to python-ideas.

My current thinking is to add both f-strings and i-strings. The f-string
version, which would be much more common, would build in the str() call
around the i-string.

Eric.



More information about the Python-ideas mailing list