Hari Sekhon wrote: > I am writing a wrapper to a binary command to run it and then do > something with the xml output from it. > > What is the best way of making sure that the command is installed on the > system before I try to execute it, like the python equivalent of the > unix command "which"?
There is the which module: http://trentm.com/projects/which/ But I'd probably just try the command and catch the exception, e.g.: >>> import subprocess >>> try: ... subprocess.call(['foo']) ... except OSError: ... print "you don't have foo installed" ... you don't have foo installed >>> try: ... subprocess.call(['svm_learn']) ... except OSError: ... print "you don't have svm_learn installed" ... 1 STeVe -- http://mail.python.org/mailman/listinfo/python-list