[issue23750] Clarify difference between os.system/subprocess.call in section "Replacing os.system()"
New submission from Andreas Sommer:
Reading over the section "Replacing os.system()" (https://docs.python.org/2/library/subprocess.html#replacing-os-system), one might assume that the return value of os.system and subprocess.call are equivalent.
status = os.system("mycmd" + " myarg")
# becomes
status = subprocess.call("mycmd" + " myarg", shell=True)
However, they are not. Example:
import sys
import os
import subprocess
print subprocess.call("false")
print os.system("false")
gives 1 and 256, respectively. Maybe this could be rephrased for clarity, or a hint added.
----------
assignee: docs@python
components: Documentation
messages: 239028
nosy: Andreas Sommer, docs@python
priority: normal
severity: normal
status: open
title: Clarify difference between os.system/subprocess.call in section "Replacing os.system()"
type: enhancement
_______________________________________
Python tracker
participants (3)
-
Andreas Sommer
-
Irit Katriel
-
Martin Panter