~lioploum/offpunk-devel

2 2

Launching shell commands from python

Details
Message ID
<168617035931.7.16743693436927443465.138846027@ploum.eu>
DKIM signature
missing
Download raw message
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
Details
Message ID
<ZIDyBFbQ2QwT0-wk@sysrq.in>
In-Reply-To
<168617035931.7.16743693436927443465.138846027@ploum.eu> (view parent)
DKIM signature
missing
Download raw message
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.
Details
Message ID
<ZIGX2fzF9yDg4WcY@sax>
In-Reply-To
<168617035931.7.16743693436927443465.138846027@ploum.eu> (view parent)
DKIM signature
missing
Download raw message
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/
Reply to thread Export thread (mbox)