On Sep 5, 2015 9:20 AM, "Guido van Rossum" <guido at python.org> wrote: > > The processing of f-strings described by the PEP uses several phases: > > - find the end of the string (the final quote[s]) using the same algorithm used for all string literals > - expand \ escapes (e.g. \uXXXX) 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 f"{ table[\"foo\"] }" > - look for single {, then scan ahead to a matching } -- this skips matching () [] {} 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 f"{ '}' }" > - look for optional !a,!r,!s and !<spec> inside each {...} pair > - take what's left, enclose it in (), parse as expression In fact maybe this whole list that Guido wrote should be copied into the PEP; it's a good summary :-). -n -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20150905/48c608ab/attachment.html>
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