3 ms·
Maybe catenation of an fString and a string should yield an fString by type promotion? String is morally "any" so it feels to me like a contextual narrowing of
by ggm 5y ago
Maybe catenation of an fString and a string should yield an fString by type promotion? String is morally "any" so it feels to me like a contextual narrowing of type.
- carl_dr 5y agoWhat if you wanted to append a string with braces, could you? (I don’t know Python!) Plus it would lead to subtle security vulns and other bugs. A contrived example : f”{bot} spammed my repo saying” + “touch(‘{path}’) was wrong lol.” Now my path var has been disclosed.
- bikingbismuth 5y agoIf you want braces in your f strings you double them up. Ex: n = "hn" print(f"hello {n} your path is {{path}}") Out: hello hn your path is {path}
- SnowflakeOnIce 5y agoStrings and f-strings are not separate types in Python, sadly.