do ls from python code example
Example: how to use the ls -l command in python
from subprocess import Popen, PIPE def listdir_shell(path, *lsargs): p = Popen(('ls', path) + lsargs, shell=False, stdout=PIPE, close_fds=True) return [path.rstrip('\n') for path in p.stdout.readlines()] dirlist = listdir_shell('/var/log', '-t')[:10] from pprint import pprint pprint(dirlist)