On this page
  1. subprocess.getstatusoutput
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

subprocess.getstatusoutput

Prev: subprocess.getoutput | Up: subprocess | Next: subprocess.Popen
Rel: subprocess.call, subprocess.CalledProcessError, subprocess.check_call, subprocess.check_output
Ref: docs.python.org — subprocess.getstatusoutput
Tags: #public #python3 #stdlib #subprocess


Import

import subprocess
from subprocess import getstatusoutput

Signature & Overview

subprocess.getstatusoutput(cmd, *, encoding=None, errors=None)

Execute the string 'cmd' in a shell with 'check_output' and return a 2-tuple (status, output). The locale encoding is used to decode the output and process newlines.

Usage

import subprocess

status, out = subprocess.getstatusoutput("echo ok")
assert status == 0 and out == "ok"

Gotchas

REPL Inspect

from subprocess import getstatusoutput
help(getstatusoutput)

Linked from

Related notes