Is there an elegant and more Python-like way to check if a package is installed on Debian?
In a bash script, I\'d do:
dpkg -s packagename | grep Stat
A slightly nicer, hopefully idiomatic version of your bash example:
import os, subprocess devnull = open(os.devnull,"w") retval = subprocess.call(["dpkg","-s","coreutils"],stdout=devnull,stderr=subprocess.STDOUT) devnull.close() if retval != 0: print "Package coreutils not installed."