Hacker News new | ask | show | jobs
by sumzup 1957 days ago

  greet = lambda x: f"hello {x}"
1 comments

What if "hello {x}" is not a static string but was read from somewhere else?

Surely this would not work:

  greeting = "hello {x}"
  greet = lambda x: f greeting
Something along the lines of...

    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
Yes, I'll stick to using str.format :)
That isn't the purpose for f-strings. You still have % and .format
You can’t use f-strings for that.
That was exactly my point.