Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This reminds me of when I first saw drop-box: Immediate recognition of the pain it will save me. I often hack up kludges that approximate this -- os.system calls that pipe to a file, then I read and parse the file. Good work.


The commands module is now deprecated by the overly complicated subprocess module, but

     content = commands.getoutput(x)
 
is much better than

     os.system(x + ' > foo') 
     content = open('foo', 'r').read()


The subprocess mode is really not that complicated. Your example can be written as:

    content = subprocess.check_output(x, shell=True)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: