Draft PEP: string interpolation with backquotes
Richard Jones
richard at bizarsoftware.com.au
Mon Dec 3 18:07:41 EST 2001
On Monday 03 December 2001 09:08, Oren Tirosh wrote:
> On Sun, Dec 02, 2001 at 02:44:22PM -0500, Tim Peters wrote:
> > Oren Tirosh wrote:
> > > The prefix "i" stands for "interpolation" or "in-line". Within
> > > a string with an "i" prefix an expression enclosed in backquotes is
> > > converted into its string representation
> >
> > That's ambiguous, and this is a real problem: Python generally has two
> > forms of "string representation", str() and repr(). Unfortunately for
> > the proposal, backticks are a shortcut for repr() but str() is probably
> > more useful in this context.
>
> I meant str(). repr() isn't very useful when embedding strings because of
> the quotes. I should have been more specific. Yes, this is inconsistent
> with the standard use of backquotes which is equivalent to repr(), not
> str(). I believe this is an acceptable compromise since it does the
> Right Thing for formatting. I wonder how ABC's backquotes worked inside
> strings.
This would then cause confusion - why not revert back to using $ as the magic
interpolation character? It has no prior history in Python and therefore no
preconceived ideas exist as to what its result might be. It does have some
history outside of Python as a string interpolation character though, in
many, many systems...
It could be either i"the value of x is $x$ and f(x) is $f(x)$" or, if there
really is a way of disambiguating it, just the leading "$"...
Richard
More information about the Python-list
mailing list