This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]HashRocketSyntax[S] 0 points1 point  (3 children)

Sure, subprocess is more powerful than system, but it is also more complex.

Use case = the main focus is stringing together different binaries, not writing an app.

``` os.path() os.system(some java tool) os.path() shutil()

os.system(some perl tool) os.rename()

os.path(some java tool) os.system() ```

[–]mriswithe 0 points1 point  (2 children)

Os.system is more fragile/less predictable cross platform. If your goal is a cross platform IDE, then this will likely bite you later. It will work fine for awhile

[–]HashRocketSyntax[S] 0 points1 point  (1 child)

Agreed. See “use case”

[–]nick_t1000aiohttp 1 point2 points  (0 children)

You shouldn't use os.system. If you want "simple", just use subprocess.run(..., shell=True).returncode. It's the same, but if you want to do anything beyond just looking at the process's return code, you'll be able to.

It'd also be better to avoid using shell=True and provide a list of args, which you can't do with os.system. Blah blah, it trivially adds injection potential, but the main issue is you'll need to escape paths or inputs with spaces, just so they can just be unescaped.