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

Suggestion: syntactic sugar for pipe calls #352

Closed
erikkemperman opened this issue Apr 16, 2019 · 4 comments
Closed

Suggestion: syntactic sugar for pipe calls #352

erikkemperman opened this issue Apr 16, 2019 · 4 comments

Comments

@erikkemperman
Copy link
Collaborator

I had this idea a while ago, and I can't decide if this is a pretty nice and pythonic idea, or else if it might be too clever by half...

So I should probably just ask the community: what do you think if we add something like this to Observable?

    def __or__(self, other):
        """Pythonic version of pipe.

        Example:
            >>> zs = xs | op          # Equivalent to zs = xs.pipe(op)
            >>> zs = xs | (op1, op2)  # Equivalent to zs = xs.pipe(op1, op2)

        Returns:
            self.pipe(*other) if other is iterable, otherwise self.pipe(other)
        """
        if isinstance(other, Iterable):
            return self.pipe(*other)
        return self.pipe(other)
@MainRo
Copy link
Collaborator

MainRo commented Apr 16, 2019

I consider such notation as a hack. Unfortunately, this is how it is done in RxCpp. I come from system/driver development and I can't adhere to a notation that abuses the usage of the "bitwise or" operator. The | character is a pipe only in shells, in python the meaning is bitwise or.
So I prefer using an explicit pipe function, unless another dedicated operator appears one day (something like https://github.com/tc39/proposal-pipeline-operator)

@dbrattli
Copy link
Collaborator

I also think we should leave it for now and hope that there will be a proper pipe operator such as with F#. Lets fix the typing problems with pipe instead #355

@erikkemperman
Copy link
Collaborator Author

Fair enough, I guess it’s a bit too hackish :-) Closing the isssue.

@lock
Copy link

lock bot commented Apr 25, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Apr 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants