News for hackers. Stuff that matters.
Re:More intuitive partial function application in Python by codethief on Sunday February 20, 2022 @08:28PM (#30410972)
`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!
Re:More intuitive partial function application in Python by memco on Sunday February 20, 2022 @09:03PM (#30411151)
What specifically bothers you about functools partial? I think the decorator is nice in certain ways. However, then you have to decorate your code and guess where you’re going toy need the partials or create wrappers just to add the decorator which seems undesirable for a number of cases. I agree that partial has warts when it comes to inspection but at least they’re easy to make anywhere you want without having to apply any changes to the callee. Nice to have another option for partials though so that when you need these features there’s a way to get them.
Re:More intuitive partial function application in Python by cgrimm1994 on Monday February 21, 2022 @09:22AM (#30416165)
I posted this below, but I can put it here too:

https://gist.github.com/chrisgrimm/64bca66f14528cfda6d865cc2...

Essentially functools.partial is somewhat limited in terms of which arguments can be partially applied.

Re:More intuitive partial function application in Python by cgrimm1994 on Monday February 21, 2022 @09:23AM (#30416173)
I'm glad you like it! This project was basically me trying to visualize how I wish functions generally worked like in Python.