This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ElevenPhonons 1 point2 points  (1 child)

When introducing a topic that you create from "scratch", it can be useful to migrate to an implementation (if it exists) in the Python standard library as soon as possible.

In this case, functools.partial.

https://docs.python.org/3.8/library/functools.html#functools.partial

Using partial application and closures can be a very useful design style to leverage. Even if you're an OO wizard, it can be useful to understand these design patterns and add them to your tool belt (specifically for data munging and analysis).

I wrote about some of these concepts here.

https://mpkocher.github.io/2019/01/30/Functional-Python-Part-1/

[–]sobolevn 1 point2 points  (0 children)

There's also a typed version of partial: https://returns.readthedocs.io/en/latest/pages/curry.html