This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eric.smith
Recipients BTaskaya, eric.smith, gvanrossum, lukasz.langa, lys.nikolaou, pablogsal
Date 2020-10-08.00:06:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1602115598.57.0.89874421661.issue41967@roundup.psfhosted.org>
In-reply-to
Content
For what it's worth, here's how f-strings with the "=" feature work:

I remember the char* pointer where the expression starts, then I parse the expression into an AST, then I note the char* pointer where the expression ended. The text between those is what's output before the equal sign []. This is how I preserve all of the whitespace inside the expression.

In my case I keep the AST to use when the expression gets evaluated, but in the string annotation case you'd throw it away. I don't think it would be very complicated to make this approach work across newlines.

[] Actually, I keep the equal sign itself and whitespace to the right of it, which is how f'{ x = }' produces " x = 42", instead of "x=42".
History
Date User Action Args
2020-10-08 00:06:38eric.smithsetrecipients: + eric.smith, gvanrossum, lukasz.langa, lys.nikolaou, pablogsal, BTaskaya
2020-10-08 00:06:38eric.smithsetmessageid: <1602115598.57.0.89874421661.issue41967@roundup.psfhosted.org>
2020-10-08 00:06:38eric.smithlinkissue41967 messages
2020-10-08 00:06:37eric.smithcreate