Apr-19-2017, 08:47 PM
(Apr-19-2017, 08:16 PM)nilamo Wrote: I thought that was only if you wanted to get the result/stdout of the command or if you didn't want to block while it ran, while os.system was fine for fire-and-forget type things?
subprocess module allows a lot of options. You may "fire and forget" - though I am not sure that's a good approach, and if you start a long process without saving reference to process object, how garbage collector will affect it.
You may capture output, redirect it to a pipe, to a file. Send input to process. Get execution results. Though I no longer see threats to discontinue
os.system
(I believe there were some), I tend to follow recommendations of documentation.I am also not sure that
os.system
is "fire-and-forget" thing - if you don't redirect stdout, it will throw it it on your terminal
Test everything in a Python shell (iPython, Azure Notebook, etc.)
- Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
- Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
- You posted a claim that something you did not test works? Be prepared to eat your hat.