I read this question in which the asker is having a specific problem with running bash in Python using code like this:
os.system(bashCommand)
The top two answers simply say: "use subprocess
" (instead of os.system
), and give a quick code example.
What is the proper way to run bash commands with Python and why? To me, it seems that os.system
is a good option, being designed for this type of thing, and it is simply a fluke that the asker of the other question couldn't accomplish correct functionality with that package. But, is it "the true Pythonic way" to use subprocess
? Or in other words, what is the difference between os.system
and subprocess
?