> Function and method chaining.
> Procedural/function syntax for chains of function calls suck. It is too 
> verbose (heavy on parentheses) and written backwards:
> print(sort(filter(transform(merge(extract(data)), args))))
To be honest, I think _this_ is the problem that I was trying to address,
with my proposed solution of implementing map reduce methods on
Iterator class. IIRC, there's already a thread on method chaining.

> There is a powerful design pattern to fix this, that works great with 
> immutable data and functions:
> https://martinfowler.com/articles/collection-pipeline/
I'll check this out!

> A long time ago, I wrote a helper class to do that:
> https://code.activestate.com/recipes/580625-collection-pipeline-in-python/?i...
> Heavy data processing frameworks and libraries like Pandas already use 
> method chaining extensively. It would be great if we could chain 
> function calls.
Saw this beauty too :)

> Shells such as bash have an excellent syntax for this:
> data | extract | merge | transform args | filter | sort | print
> Method chaining is good too:
> data.extract().merge.transform(args).filter().sort().print()
> except for the downsides discussed previously. It would be very, very 
> nice if we had syntactic sugar for that chain of function calls that 
> would work on general functions and methods.
This syntactic sugar would definitely increase readability. I remember
Elixir has something similar like |> to indicate the data flow.
_______________________________________________
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/O3M7PABOKWJLO4TTHTEJCW7TYFCWHDAG/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to