Skip to content
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

Fix join pipe function #23

Open
akshayphilar opened this issue Nov 13, 2019 · 2 comments
Open

Fix join pipe function #23

akshayphilar opened this issue Nov 13, 2019 · 2 comments
Labels
bug Something isn't working

Comments

@akshayphilar
Copy link
Member

No description provided.

@akshayphilar akshayphilar added the bug Something isn't working label Nov 30, 2019
@akshayphilar akshayphilar added this to the Fixes and Documentation milestone Nov 30, 2019
@renancunha
Copy link
Contributor

I don't know exactly the purpose of this issue, but I'll describe a situation that I found using the join pipe and that deserves some discussion about it.

Generally, all shublang functions are executed through the iterable that they receive. But the join pipe is executed joining the iterable by a string. I think that instead of joining the iterable, it should apply the join operation on every item of the iterable.

In other words, instead of having the join function like this:

def join(iterable, separator=", "):
    return separator.join(builtins.map(str, iterable))

we should have:

def join(iterable, separator=", "):
    return (separator.join(builtins.map(str, x)) for x in iterable)

I came to this analyzing the following situation:

  • Every time that I get data from a previous pipe like jmespath, I need to add a first, before using the join pipe. Another problem with the current approach is that they are returning a string, instead of an iterable. I think that we should be careful with the grammar in situations like this, to keep the shublang terse.

What do you think about it?
cc @BurnzZ @akshayphilar

@akshayphilar
Copy link
Member Author

@renancunha you have captured the intent of this issue. Agree, join needs to be brought in line with other pipe functions as you have described above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants