On 03/02/2016 03:36 PM, Marko Rauhamaa wrote: > Requirements for what I have in mind: > > 1. It would have to be and feel like real Python. > > 2. External commands should be available as callable Python functions. > > 3. Functions/commands should return streams. (Generators, maybe?) > > 4. Pipelines should have an intuitive syntax (but still be valid > Python). > > Requirements 3 and 4 apply to regular Python code as well.
I've thought about this before and even tried my hand at creating a nice library for doing this sort of thing with Python. Generators seem like a natural analog for the shell pipes. However there is one big problem with them and that is they can only deal with one stream at a time. Whereas in shell programming there are 2 streams that you can use and connect simultaneously. For example I can simultaneously pipe standard out from a program to another command whilst piping standard error to another. I never figured out a way to emulate this idea of piping multiple streams. In the end I decided that Python's superior text processing facilities eliminated 90% of the reason to use pipes. And for the other 10%, generators worked extremely well and efficiently. http://www.dabeaz.com/generators/Generators.pdf When I was doing a lot of shell scripting in Python I wrote my own wrapper routine to launch programs and obtain stdout and stderr, which I could process with generator filters and that worked fairly elegantly for many things. Kind of a half-way approach but it worked well. -- https://mail.python.org/mailman/listinfo/python-list