Hey,
I’ve found this very interesting article about how to use command-line
tool from within a python script.
https://martinheinz.dev/blog/98
The recommended approach is to use the "sh" python module, something I
didn’t know.
Regarding our own history with python subprocesses, I think it worth
keeping this reference and I would be curious to know if you have
feedback about it.
I’m also curious to know if python3-sh is widely used/packaged or if
that would be "yet another exotic dependency".
Cheers,
--
Ploum - Lionel Dricot
Blog: https://www.ploum.net
Livres: https://ploum.net/livres.html
On 2023-06-07 20:39, Ploum wrote:
> I’m also curious to know if python3-sh is widely used/packaged or if > that would be "yet another exotic dependency".
You can find such info on Repology:
https://repology.org/project/python:sh/versions
139 packages and 26 families is a good number.
Ploum (2023-06-07 20:39:02 +0000) wrote:
> I’ve found this very interesting article about how to use command-line > tool from within a python script.> > https://martinheinz.dev/blog/98> > The recommended approach is to use the "sh" python module, something I > didn’t know. […]
Umm, the article has interesting references and `sh` looks handy, but I
wouldn't say that it's the "right" way of running shell commands, as the
article author puts it. It does provide some syntactic sugar and execution
logging (I don't know how context managers like `sudo` affect the other
approaches), so "convenient" may be a more adequate term. Unless there's
something else that `sh` does *right* while others like `subprocess` do
*wrong*, that is.
Cheers,
--
Ivan Vilata i Balaguer -- https://elvil.net/