Date Archives September 2016

os.system() vs.



  • executed in a subshell, usually bash on linux and OSX, and cmd.exe on windows.
  • The shell will take the string given and interpret the escape characters.
    • ex)  os.system(“python –version”)

  • default does not use a shell – it simply tries to run an executable with a name given by string a. You actually can’t pass any arguments in the string a – only the literal name of the executable.
  • To run a command with arguments, I need to give this to as a list
    • ex)[“python”, “–version”]) can be used same as os.system() by setting shell to true.

  • ex)“python –version”, shell=True)