Hacker News new | ask | show | jobs
by carl_dr 1517 days ago
What 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.

1 comments

If 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}