Skip to content

Instantly share code, notes, and snippets.

@jamesob
Created March 13, 2014 17:06
Show Gist options
  • Save jamesob/9532528 to your computer and use it in GitHub Desktop.
Save jamesob/9532528 to your computer and use it in GitHub Desktop.
The Python snippet that obviated Bash forever
import subprocess
from collections import namedtuple
CallResult = namedtuple('CallResult', 'code,output')
def call(cmd):
try:
return CallResult(0, subprocess.check_output(cmd, shell=True))
except subprocess.CalledProcessError as e:
return CallResult(e.returncode, e.output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment