Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #105090
| From | Marko Rauhamaa <marko@pacujo.net> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Bash-like pipes in Python |
| Date | 2016-03-17 14:44 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <87d1qtb7fr.fsf@elektro.pacujo.net> (permalink) |
| References | <56e97459$0$1600$c3e8da3$5496439d@news.astraweb.com> <mailman.217.1458141621.12893.python-list@python.org> <56ea8ded$0$1614$c3e8da3$5496439d@news.astraweb.com> <87mvpxb9zi.fsf@elektro.pacujo.net> <mailman.271.1458216615.12893.python-list@python.org> |
Sivan Greenberg <sivan@vitakka.co>:
> If I understand correctly, the binary right or overloading that's seen
> here can be applied to any other computational objects.
>
> I could also think of implementing it for input / output pipes
> overloading the __ror__ method with .communicate() method of the Popen
> object [0].
I'm thinking it's all of the above and more!
At the bottom is the generic pipelining of generators.
Then there's the special case of integrating external commands with the
generic framework:
cmd('cat /etc/passwd', stdin=None) | List
(Is "stdin=None" needed?)
Then there's the enriching of data formats. The line-based delineation
is old-school and unsafe, and should be considered for legacy only. The
internal data format is arbitrary Python object sequences, but
externally, JSON should be preferred. Thus, we'll need converters
from/to JSON.
What is still missing is the true generator lambdas:
produce_data | (
lambda name, value:
yield value) | \
consume_values
as in bash:
produce_data |
while read name value; do
echo $value
done |
consume_values
Marko
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Bash-like pipes in Python Steven D'Aprano <steve@pearwood.info> - 2016-03-17 01:57 +1100
Re: Bash-like pipes in Python Joel Goldstick <joel.goldstick@gmail.com> - 2016-03-16 11:09 -0400
Re: Bash-like pipes in Python Christian Gollwitzer <auriocus@gmx.de> - 2016-03-16 16:16 +0100
Re: Bash-like pipes in Python Random832 <random832@fastmail.com> - 2016-03-16 11:20 -0400
Re: Bash-like pipes in Python Steven D'Aprano <steve@pearwood.info> - 2016-03-17 21:58 +1100
Re: Bash-like pipes in Python Marko Rauhamaa <marko@pacujo.net> - 2016-03-17 13:49 +0200
Re: Bash-like pipes in Python Sivan Greenberg <sivan@vitakka.co> - 2016-03-17 14:10 +0200
Re: Bash-like pipes in Python Marko Rauhamaa <marko@pacujo.net> - 2016-03-17 14:44 +0200
Re: Bash-like pipes in Python "Sven R. Kunze" <srkunze@mail.de> - 2016-03-16 16:20 +0100
Re: Bash-like pipes in Python Random832 <random832@fastmail.com> - 2016-03-16 11:21 -0400
Re: Bash-like pipes in Python Steven D'Aprano <steve@pearwood.info> - 2016-03-17 02:39 +1100
Re: Bash-like pipes in Python Marko Rauhamaa <marko@pacujo.net> - 2016-03-16 19:04 +0200
Re: Bash-like pipes in Python Steven D'Aprano <steve@pearwood.info> - 2016-03-18 01:10 +1100
Re: Bash-like pipes in Python Chris Angelico <rosuav@gmail.com> - 2016-03-18 01:36 +1100
Re: Bash-like pipes in Python Random832 <random832@fastmail.com> - 2016-03-17 12:31 -0400
Re: Bash-like pipes in Python Sivan Greenberg <sivan@vitakka.co> - 2016-03-17 19:20 +0200
csiph-web