4 ms·
Yawn… Python sucks for building processing pipelines. How many lines of Python code would you need to implement this? paste -d \\n <(foo …) <(bar …) | whil
by aaaaaaaaaaab 4y ago
Yawn…
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.
- slt2021 4y agoreplace bash one-liner with python? No, thanks replace 200+ bash script with multiple subroutines in python? yes
- dmtroyer 4y agoas someone who is maintaining mountains of legacy bash, for all that is holy, yes. or Go. or Rust. anything.
- idispatch 4y agoMind you, before this goes to prod please add error handling and logging. What happens when bar fails? What about baz? Now, please rewrite this so your team mates can maintain and extend. Yawn, I’ll wait for the PR.
- aaaaaaaaaaab 4y agoGotcha, thanks for the feedback! We should also totally A/B test this! I'll make sure that this ties in with the quarterly OKRs, too! I hope I'll get promoted to E6 for that sweet 10% raise next cycle :fingers_crossed:
- d0mine 4y agoNothing stops you from calling bash from Python to combine bash pipelines (onelines) but if you must use Python for some reason, to run `baz` for each line in `foo` & `bar` output: 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)