greeting = "hello {}"
greet = partial(str.format, greeting)
greet("world")
How would you pass a variable format string to f"" ? greeting = "hello {}"
greet = partial(str.format, greeting)
greet("world")
How would you pass a variable format string to f"" ? >>> flt = 1.2345
>>> two = 2
>>> f"{flt:.{two}f}"
'1.23' greet = lambda x: f"hello {x}" greet = lambda x: f"hello {x}"Surely this would not work:
greeting = "hello {x}"
greet = lambda x: f greeting code = 'f"{input()} {x}"'
lambda x: eval(code)
(Please don't do this) code = 'f"here it is {eval(input())}"'
(lambda: eval(code))()
k, there we go greet_fstring = partial(lambda _,s: f"hello {s}", greeting) greet = partial(str.format, greeting)
greet("world")
as opposed to just greeting.format("world")
? greet = greeting.format