On Sep 5, 2015 9:20 AM, "Guido van Rossum" <gu...@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
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com