News for hackers. Stuff that matters.
Re:Python 3's F-Strings: An Improved String Formatting Syntax by quietbritishjim on Wednesday January 20, 2021 @03:56PM (#25851884)
You can use any of

    f"{foo['field']}"
    f'{foo["field"]}'
    f"""{foo["field"]}"""
(I see from your carefully worded first sentence that you already knew this but still find it annoying, but I'll leave this here for any that aren't aware.)
Re:Python 3's F-Strings: An Improved String Formatting Syntax by mixmastamyk on Wednesday January 20, 2021 @04:10PM (#25852032)
Yes, and anyone who has written a "one-liner" at the command line is familiar with it. Wouldn't say it is a big problem.
Re:Python 3's F-Strings: An Improved String Formatting Syntax by psalminen on Wednesday January 20, 2021 @06:06PM (#25853128)
The problem with this is when you run it through a formatter that changes all ' to ".
Re:Python 3's F-Strings: An Improved String Formatting Syntax by dmurray on Wednesday January 20, 2021 @06:29PM (#25853300)
Sounds like a bug in your formatter, if it's meant to just do formatting but actually replaces valid syntax with invalid.
Re:Python 3's F-Strings: An Improved String Formatting Syntax by psalminen on Wednesday January 20, 2021 @06:41PM (#25853393)
I don't totally disagree. My company uses the black formatter, which does this[0]. There are flags to skip string formatting, but is frowned upon at my organization.

[0] https://github.com/psf/black/blob/master/docs/the_black_code...

Re:Python 3's F-Strings: An Improved String Formatting Syntax by nimih on Wednesday January 20, 2021 @06:59PM (#25853552)
For what it's worth, black appears to do a reasonable thing and preserves the semantics of your quoted strings (as is promised by the documentation):

  $ echo "'foo'" | black -
  "foo"
  
  $ echo "'foo[\"bar\"]'" | black -
  'foo["bar"]'

  $ echo "'foo[\"bar\"]+\\'baz\\''" | black -
  "foo[\"bar\"]+'baz'"