Showing content from http://mail.python.org/pipermail/python-dev/attachments/20150905/48c608ab/attachment.html below:
<p dir="ltr">On Sep 5, 2015 9:20 AM, "Guido van Rossum" <<a href="mailto:guido@python.org">guido@python.org</a>> wrote:<br>
><br>
> The processing of f-strings described by the PEP uses several phases:<br>
><br>
> - find the end of the string (the final quote[s]) using the same algorithm used for all string literals<br>
> - expand \ escapes (e.g. \uXXXX)</p>
<p dir="ltr">It might be worth calling out explicitly in the text how this works for what I suspect will be the most common case: embedded quoting embedded quotes, like</p>
<p dir="ltr">Â Â Â f"{ table[\"foo\"] }"</p>
<p dir="ltr">> - look for single {, then scan ahead to a matching } -- this skips matching () [] {}</p>
<p dir="ltr">I assume this part of the algorithm uses the lexer and scans for matching tokens rather than just scanning for characters? I tried looking at the PEP to double check but couldn't find the relevant part. It's important for things like</p>
<p dir="ltr">Â Â Â Â f"{ '}' }"</p>
<p dir="ltr">> - look for optional !a,!r,!s and !<spec> inside each {...} pair<br>
> - take what's left, enclose it in (), parse as expression</p>
<p dir="ltr">In fact maybe this whole list that Guido wrote should be copied into the PEP; it's a good summary :-).</p>
<p dir="ltr">-n</p>
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4