command substitution at at
Wed Jul 18 03:08:51 EDT 2001

Hi Raphaël,

I think you can define a function like :

import os, string
def GetStdOut(cmd):
	pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r')
	return string.split(string.strip(,'\n')

then :

Hao-Nghi Au

-----Original Message-----
From: Raphael Bauduin [mailto:rb at]
Sent: Monday, July 16, 2001 10:35 AM
To: python-list at
Subject: command substitution


I was looking for a solution like in bash, which let you put the standard 
output of a command in a variable(in bash, you can do it like OUT=`ls` or 
OUT=$(ls) ).

If you have another way to take the standard output of a command and put it 
in a variable, it would be helpfull too.


          Open Source and Free Software Developers Meeting
See you at the 2002 edition. Check the 2001 sessions on
     Visit and subscribe to the mailing list!

More information about the Python-list mailing list