Hacker News new | ask | show | jobs
by gvalkov 2867 days ago
I think you're making this more complicated than it needs to be. For simple things, it's ok to just:

  from subprocess import run
  run('foo | bar', shell=True, check=True)
1 comments

As that argument's name suggests, that's invoking a shell (or whatever the `shell` env var is set to, IIRC).

Shells are excellent at invoking commands and piping, as I said.

Doing things like piping with Python instead of a shell is indeed more complicated than it needs to be. That was my point ;)