4 ms·
I haven't run it but I'm quite sure you can do this to get direct pipe without having to run foo to completion before starting bar: foo = subprocess.Popen(
by Too 8y ago
I haven't run it but I'm quite sure you can do this to get direct pipe without having to run foo to completion before starting bar:
foo = subprocess.Popen(['foo'], stdout=subprocess.PIPE)
bar_output = subprocess.check_output(['bar'], stdin=foo.stdout)
Though the idea with python is that you shouldn't have to do as much piping as you do in bash, no need for xargs, cut, find, etc. Just process the data inside python code. So the pain of having to use two lines instead of a | isn't as big as many people claim.