> To me, the most natural syntax looks like this:
> value | function *args, **kwargs
> equivalent to `function(value, *args, **kwargs)` but of course we've 
> already used the pipe for bitwise-or and set intersection. `>>` would be 
> another equally good operator. I don't really like `|>` as an operator. 
> If we were to invent a new operator, I'd prefer `->`.
This syntactic sugar imo is powerful because it's not limited to iterables 
but generalises to possibly any object. But I guess since method chaining 
(for collection pipeline) is more commonplace across many languages, it 
might be easier to catch on.

> We can experiment by providing a wrapper class that takes a function, 
> method or other callable and gives them a `__ror__` method for the pipe, 
> and a `.p` (for partial) method for the partial application:
> value | Wrapper(function).p(*args, **kwargs)
>     --> partial(function, *args, **kwargs)(value)
> That's sufficient for experimentation, but needing that wrapper adds too 
> much friction. Ultimately nobody is going to use this idiom to its full 
> potential until it works with arbitrary functions and callables without 
> the wrapper.
I also agree that using this wrapper might be too much friction. I think 
this would be similar to Simple Smart Pipe 
(https://github.com/sspipe/sspipe).

> I would be willing to help design an API and write a PEP but I would 
> *not* champion it for 3.11.
Awesome, Steven 😊
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/HCD457RTAWZM5E7DXNZ7ZQVZA6ZVPJWC/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to