Drkcore

14 08 2010 Python Tweet

Pythonで外部コマンドがPATHに存在するか探す

SWIGでgastonのPythonバインディング作るのがいいのかもしれないけど、SWIG力が足りないので、外部コマンドから使っている。

os.environ['PATH']で探してみたけど、普通はどうやるんだろうか

if 'gaston' not in reduce(lambda a,b: a+b,[os.listdir(d) for d in \
    os.environ['PATH'].split(':') if os.path.isdir(d)]):
    print "gaston: command not found"
    exit()
os.system("gaston %d %s %s > /dev/null 2>&1" % (freq,gasfile,output))

About

  • もう5年目(wishlistありマス♡)
  • 最近はPythonとDeepLearning
  • 日本酒自粛中
  • ドラムンベースからミニマルまで
  • ポケモンGOゆるめ

Tag

Python Deep Learning javascript chemoinformatics Emacs sake and more...

Ad

© kzfm 2003-2021