Feb-16-2020, 03:53 AM
you might want to put this script in your python examples folder. you won't likely ever need to do this, but if some day you need to dynamically change the format of an f-string at run time (normally, python constructs code from an f-string at compile time when it reads in the source file), this can be a great reminder example of how to set it up.
silly = 'crazy' exs = ['hellp {silly} world', """hey {silly}, this script is {silly.upper()}!""", "1 + 1 = {1+1} ... how {silly}!"] for ex in exs: result = eval(f'f{ex!r}') print(result)always use a trusted source of all characters for an f-string format. using untrusted sources like user input over the internet can get your script exploited by the black hats.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.