Use os.popen() : tmp = os.popen("ls").read(). The newer way (> python 2.6) to do this is to use subprocess :
stackoverflow.com