Python sh Package
Was listening to Late Night Linux and sh was mentioned. This looks like a good replacement for subprocess though this will only work with Unix-like systems and not Windows though I would think it will work with WSL.
Below is the summary from sh’s website.
sh is a full-fledged subprocess replacement for Python 3.8 - 3.11, PyPy that allows you to call any program as if it were a function:
| |
Output:
| |
Note that these aren’t Python functions, these are running the binary commands on your system by dynamically resolving your $PATH, much like Bash does, and then wrapping the binary in a function. In this way, all the programs on your system are easily available to you from within Python.