News for hackers. Stuff that matters.
Re:Pattern matching accepted for Python by sumzup on Tuesday February 09, 2021 @05:40PM (#26083431)

  greet = lambda x: f"hello {x}"
Re:Pattern matching accepted for Python by linkdd on Tuesday February 09, 2021 @06:10PM (#26083765)
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
Re:Pattern matching accepted for Python by staticassertion on Tuesday February 09, 2021 @06:14PM (#26083802)
Something along the lines of...

    code = 'f"{input()} {x}"'

    lambda x: eval(code)
(Please don't do this)
Re:Pattern matching accepted for Python by staticassertion on Tuesday February 09, 2021 @11:36PM (#26085783)

    code = 'f"here it is {eval(input())}"'
    (lambda: eval(code))()
k, there we go
Re:Pattern matching accepted for Python by linkdd on Tuesday February 09, 2021 @06:16PM (#26083832)
Yes, I'll stick to using str.format :)
Re:Pattern matching accepted for Python by klyrs on Wednesday February 10, 2021 @01:33AM (#26086230)
That isn't the purpose for f-strings. You still have % and .format
Re:Pattern matching accepted for Python by AlphaSite on Tuesday February 09, 2021 @08:28PM (#26084809)
You can’t use f-strings for that.
Re:Pattern matching accepted for Python by linkdd on Tuesday February 09, 2021 @10:18PM (#26085399)
That was exactly my point.