capturing output of os.system() into a list?

Richard Jones richard at
Wed Dec 12 20:30:36 EST 2001

On Thursday 13 December 2001 12:06 pm, Ron wrote:
> Is there a built-in method of doing this?  I can write a function
> to do it, but would rather use the standard method.

something like:

>>> import os
>>> os.popen('ls').readlines()
['addDataManager.dtml\n', 'addExtDataContainer.dtml\n', 
'addIdManager.dtml\n', 'CHANGES.txt\n', '\n', 'common.pyc\n', 
'dtml\n', 'help\n', '\n', '__init__.pyc\n', 
'\n', 'LowConflictConnection.pyc\n', 
'manageDataManager.dtml\n', 'manageExtDataContainer.dtml\n', 
'manageIdManager.dtml\n', 'manageImpExpSessionData.dtml\n', 
'manageIntDataContainer.dtml\n', 'manageSessionData.dtml\n', 'othertests\n', 
'README.txt\n', '\n', 'SessionDataContainer.pyc\n', 
'\n', 'SessionDataManager.pyc\n', '\n', 
'SessionData.pyc\n', '\n', 'SessionIdManager.pyc\n', 
'\n', 'SessioningInterfaces.pyc\n', 
'\n', 'SessioningPermissions.pyc\n', 
'\n', 'SessionStorage.pyc\n', 'tests\n', 'TODO.txt\n', 
'VERSION.txt\n', 'www\n']


More information about the Python-list mailing list