I'm a big fan of first-class functions (or similar) and functional code, but lambdas are in the end just syntactic sugar. Why not just write:
"!": math.factorial,
The lambda wrapper isn't doing anything here.
Re:Lambdas and Functions in Python
by guitarbill on Saturday June 16, 2018 @06:38PM
(#17329864)
I also thought that, but `math.factorial` is a builtin, and so you cannot get the signature of it, and the code can't determine how many operands the command needs. This is similar to the `self.stack.clear()` example. (`signature(math.factorial)` gives "ValueError: no signature found for builtin <built-in function factorial>")
“!”: lambda x: math.factorial(x),
However, it’s probably a matter of taste... but I do like the last code more. :)