SyntaxFix
Write A Post
Hire A Developer
Questions
Another way is:
f = open("|ls") foo = f.read()
Note that's the "pipe" character before "ls" in open. This can also be used to feed data into the programs standard input as well as reading its standard output.