by aaaaaaaaaaab · 4y ago · 0 comments
Python sucks for building processing pipelines.
How many lines of Python code would you need to implement this?
paste -d \\n <(foo …) <(bar …) | while read -r f && read -r b; do
baz “$f” “$b”
done
Mind you, `foo` and `bar` run in parallel. from subprocess import Popen, PIPE, run
with Popen('foo', stdout=PIPE) as foo, Popen('bar', stdout=PIPE) as bar:
for f, b in zip(foo.stdout, bar.stdout):
run(['baz', f, b])
(there is a slight difference in behaviour)