7 ms·
Hey, 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 accompli
by cgrimm1994 5y ago
Hey, 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!
- codethief 5y ago`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!
- cgrimm1994 5y agoI'm glad you like it! This project was basically me trying to visualize how I wish functions generally worked like in Python.
- memco 5y agoWhat 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.
- cgrimm1994 5y agoI posted this below, but I can put it here too: https://gist.github.com/chrisgrimm/64bca66f14528cfda6d865cc21fe77d4 https://gist.github.com/chrisgrimm/64bca66f14528cfda6d865cc2... Essentially functools.partial is somewhat limited in terms of which arguments can be partially applied.