Python Forum
moving from os to subprocess
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
moving from os to subprocess
#7
They are basically the same. The call() method returns the return code of the executed command.

retcode = subprocess.call(['ls', '-l'])
print(retcode)
Output:
0
You can do the same with run() method but the return code is as an attribute to the returned object:

subprocess.run(['ls', '-l']).returncode
Same output

Ref: https://docs.python.org/3/library/subpro...-level-api
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Messages In This Thread
moving from os to subprocess - by Barrowman - Dec-17-2017, 04:11 PM
RE: moving from os to subprocess - by wavic - Dec-17-2017, 05:59 PM
RE: moving from os to subprocess - by Barrowman - Dec-17-2017, 06:19 PM
RE: moving from os to subprocess - by Barrowman - Dec-17-2017, 07:59 PM
RE: moving from os to subprocess - by wavic - Dec-17-2017, 10:35 PM
RE: moving from os to subprocess - by Barrowman - Dec-17-2017, 11:02 PM
RE: moving from os to subprocess - by wavic - Dec-17-2017, 11:28 PM
RE: moving from os to subprocess - by Barrowman - Dec-18-2017, 09:04 AM
RE: moving from os to subprocess - by wavic - Dec-19-2017, 10:20 PM
RE: moving from os to subprocess - by ezdev - Dec-20-2017, 01:02 AM
RE: moving from os to subprocess - by Barrowman - Dec-20-2017, 09:08 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020