<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Jul 21, 2015 at 6:50 PM, Oscar Benjamin <span dir="ltr"><<a href="mailto:oscar.j.benjamin@gmail.com" target="_blank">oscar.j.benjamin@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><span><div dir="ltr">On Tue, 21 Jul 2015 at 14:14 Nick Coghlan <<a href="mailto:ncoghlan@gmail.com" target="_blank">ncoghlan@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I wonder though, if we went with the f-strings idea, could we make<br>
them support a *subset* of the "str.format" call syntax, rather than a<br>
superset? What if they supported name and attribute lookup syntax, but
not positional or subscript lookup?<br></blockquote><div><br></div></span><div>Please don't do either. Python already has a surplus of string formatting mini-languages. Making a new one that is similar but not the same as one of the others is a recipe for confusion as well as an additional learning burden for new users of the language.<br></div></div></div></blockquote><div><br></div><div>I'm not sure if you meant it this way, but if we really believed that, the only way to avoid confusion would be not to introduce f'' strings at all. (Which, BTW is a valid outcome of this discussion -- even if a PEP is written it may end up being rejected.)<br><br></div><div>Personally I think that the different languages are no big deal, since realistically the far majority of  use cases will use simple variables (e.g. foo) or single attributes (e.g. foo.bar).<br><br>Until this discussion I had totally forgotten several of the quirks of PEP 3101, including: a[c] meaning a['c'] elsewhere; the ^ format character and the related fill/align feature; nested substitutions; the top-level format() function. Also, I can never remember how to use !r.<br><br></div><div>I actually find quite unfortunate that the formatting mini-language gives a[c] the meaning of a['c'] elsewhere, since it means that the formatting mini-language to reference variables is neither a subset nor a superset of the standard expression syntax. We have a variety of other places in the syntax where a slightly different syntax is supported (e.g. it's quite subtle how commas are parsed, and decorators allow a strict subset of expressions) but the formatting mini-language is AFAIR the only one that gives a form that is allowed elsewhere a different meaning.<br><br></div></div>-- <br><div>--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div></div>