3 ms·
> don't allow for partial application Unfortunately, partial application doesn't work in Python, the same way it works in Haskell. If a function has 3 args, ca
by gnulinux 4y ago
> don't allow for partial application
Unfortunately, partial application doesn't work in Python, the same way it works in Haskell. If a function has 3 args, calling `f(x)` is a guaranteed runtime `TypeError`. There is functools.partial to hack it into the language for cases where you absolutely need it but overall it's bad developer experience. In fact, when I do need to partially apply `f(x, y, z)` I much prefer doing `g = lambda y, z: f(fixed_x, y, z)` because it's clearer than using functools.partial.
- nerdponx 4y agoI don't agree that the `lambda` is clearer than `partial`. This is a matter of personal style and preference, and IMO the top priority in cases like this is consistency within the codebase. You can also refactor partial function applications into callable classes depending on your needs, which is basically what `functools.partial` does internally anyway.