Except a linter or static analyzer can easily be taught to understand f"", but it's essentially impossible to reason statically about locals().
Re:New string formatting in Python
by mixmastamyk on Sunday January 03, 2016 @11:20PM
(#10833968)
> Thing is, * * locals() "feels dirty" but does exactly the same thing as f''
That's false, it does not do that. It converts the string into the equivalent format call at compile-time. RTFP ;)
The best way imho would be:
Easy and extremely unlikely to ever include the wrong variable.