[Python-ideas] Draft PEP on string interpolation

Terry Reedy tjreedy at udel.edu
Mon Aug 24 02:23:47 CEST 2015


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?

-- 
Terry Jan Reedy



More information about the Python-ideas mailing list