News for hackers. Stuff that matters.
Re:New string formatting in Python by toyg on Sunday January 03, 2016 @09:42PM (#10833744)
Thing is, * * locals() "feels dirty" but does exactly the same thing as f''. Except f'' does it implicitly, hiding dirt under the carpet. One day, that dirt will turn something into a bug; which is exactly why the Zen says "explicit is better than implicit".

The best way imho would be:

    vars = {'short1': very_long_var_name1, 
            'short2': very_long_var_name2}
    print('{short1} {short2}'.format(**vars))
Easy and extremely unlikely to ever include the wrong variable.
Re:New string formatting in Python by spicyj on Sunday January 03, 2016 @09:58PM (#10833789)
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 ;)