-
-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Starmap #83
Comments
What about: @Pipe
def starmap(iterable, selector):
for element in iterable:
yield selector(*element) ? |
Yeah this is better. I'm happy to work on a PR if you think its worth adding? |
I'm not in favor of adding pipes to the module: it would lead to an infinite number of pipes each usefull to only a handfull of people. I prefer to see the module and the readme as a way to teach people how to do their own specific pipes tailored for their own jobs. Yes I fear the case when someone don't find the needed pipe in the module and goes away instead of implementing it, while my module is here to provide the syntax, not the implementations. But I like your starmap idea, can you please add a section in the README, after "Constructing your own", titled maybe "Recipes" and putting it here? I would accept such a PR. It would be a nice way not to loose it, and would be a nice way to encourage people to write their own @pipe functions freely. |
Yeah can do - I appreciate the sentiment of what you want this library to do. And for such easy to implement functionality its not an issue re-creating it when you need it. I like the recipes idea too, will put a PR up for this |
You could also create a repository (or even pypi package) that depends on pipe and which includes a collection of "custom pipes". This would leave the core package (pipe) as compact as it is, but there could still be a package -- or repository -- available that provides all kinds of pipes.
from pipe_collection import starmap
... |
@jeff-dh Yes, it would work! Sadly for the moment I don't have much to add to it, so I won't do it in the near future. Anyone interested in maintaining this is obviously free and encouraged to do it. |
As @JulienPalard said earlier, it can be a solution to have a collection for different pipes, but there is a problem: if you have a large number of functions, the initialization time will be very high, even if you use only one function, all the others must be defined. Is it worth it? |
Hi,
I was thinking of submitting a PR with a starmap function, something like this:
This is really useful in situations where you have an iterable of args that you want to pass to a function and have them unpacked positionally. An example might be in parsing a row of values into a datamodel E.g:
This is what you get:
Makes it much simpler than doing something like this (especially when you have a large number of values to map):
I couldn't find anything resembling a starmap but if there is another way to achieve this let me know.
The text was updated successfully, but these errors were encountered: