News for hackers. Stuff that matters.
Re:Formalizing Python F-Strings by tragomaskhalos on Saturday January 14, 2023 @05:26AM (#34379076)
The f-string annoyance that dwarfs all others is forgetting the bloody f, and the associated forehead slap when the console says "the answer to your big calculation is {answer}" (sic). Unfortunately I'm not sure there's any clever language solution to that.
Re:Formalizing Python F-Strings by layer8 on Saturday January 14, 2023 @05:34AM (#34379115)
Proper syntax highlighting should solve this.
Re:Formalizing Python F-Strings by brennvin on Saturday January 14, 2023 @05:57AM (#34379216)
What if the compiler issued a warning if the f was missing and let you suppress the warning with an r?
Re:Formalizing Python F-Strings by setr on Saturday January 14, 2023 @06:28AM (#34379409)
Then it might as well be fstrings by default, rstrings for raw.
Re:Formalizing Python F-Strings by brennvin on Saturday January 14, 2023 @06:44AM (#34379503)
Good idea! If we do away with f strings entirely the problem does not occur.
Re:Formalizing Python F-Strings by cricalix on Saturday January 14, 2023 @06:22AM (#34379363)
It's not a language solution, but an AST based linter perhaps? PyCQA might have one already; they definitely have a "consider using f-strings" lint you can turn on.