This assumes /dev/fd support on your platform. Shells fall back to named pipes on platforms where /dev/fd is not present, but I haven't reproduced that behavior here.
For expressing pipelines in a more compact and intuitive way, PyPI has packages like sh or plumbum. While they don't seem to support process substitution out of the box, it looks like it wouldn't be too hard to extend them.
Looks like there are two different problems here:
For the first one, I would rewrite your shell code as follows:
This assumes
/dev/fd
support on your platform. Shells fall back to named pipes on platforms where/dev/fd
is not present, but I haven't reproduced that behavior here.For expressing pipelines in a more compact and intuitive way, PyPI has packages like
sh
orplumbum
. While they don't seem to support process substitution out of the box, it looks like it wouldn't be too hard to extend them.