More intuitive partial function application in Python
1–10 of 36 posts
Re: More intuitive partial function application in Python
#2Re: More intuitive partial function application in Python
#3In practice i worry about static checkers and IDE param hints though, how have you fared with these?
Not your fault at all, but mypy/pyright have very poor support for wrappers like this, and in IDEs it's common for their arg hints to devolve to a copout (args, kwargs) as well.
Re: More intuitive partial function application in Python
#4Hey, I use functools.partial a lot in my projects and I've always felt like it was pretty limited in the types of partial function application it could accomplish. I put together a modified version of partial over the weekend that I wanted to share / get feedback on. Let me know what you all think!
Re: More intuitive partial function application in Python
#5Re: More intuitive partial function application in Python
#6Re: More intuitive partial function application in Python
#7Re: More intuitive partial function application in Python
#8Could you compare it to functools.partial?
In the example on the Readme:
import better_partial as bp
@bp.partial
def some_operation(x, p1, p2):
return (x + p1) * p2
It claims that the bp approach is superior because: func = some_operation(bp._, 10, 20)
...is better than: func = lambda x: some_operation(x, 10, 20)
But is it better than just: partial(some_operation, p1=10, p2=20)
?Re: More intuitive partial function application in Python
#9Re: More intuitive partial function application in Python
#10Hey, I use functools.partial a lot in my projects and I've always felt like it was pretty limited in the types of partial function application it could accomplish. I put together a modified version of partial over the weekend that I wanted to share / get feedback on. Let me know what you all think!
`functools.partial` has been bothering me for a long time and I've always thought it'd be nice to have something like the placeholder `·` that people use in math (i.e. `f(·, y, z)`). It didn't occur to me that a decorator might actually get us there without having to introduce new syntax. Nice project!