Python's functools.partial() Lets You Pre-Fill A Function

https://thepythoncodingstack.substack.com/p/pythons-functools-partial-and-partialmethod

An exploration of partial() and partialmethod() in functools

13 points · 4 comments · view on lemmy.world

4 Comments

henfredemars@infosec.pub · 3 pts · 3y (2 replies)

I'm disappointed that the article doesn't address why it's better than just using lambda.

brettvitaz@programming.dev · 1 pts · 3y (1 reply)

I'm disappointed

Why? It’s not better or worse, just different. Lambdas have their use case, as does function partials and wraps.

Spott@lemmy.world · 3 pts · 3y

They are different though, and the article doesn’t go into why they are different, which I think is a major omission (though a common one in articles about this subject).

The difference is that lambda functions are late binding, while partial functions are bound when they are created. This can lead to all sorts of hard to find bugs when using lambdas that are avoided by using partials.