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

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)




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

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

Search: