Easy way to store stdout to a variable?
mmarsh at di.mdacc.tmc.edu
Tue Mar 11 17:38:02 CET 2003
Thanks Alex. That worked great.
Alex Martelli <aleax at aleax.it> wrote in message news:<fSWaa.32905$pG1.776432 at news1.tin.it>...
> mike wrote:
> > unix pipes and filters, e.g. "ls *.txt | grep -v old | wc -l".
> > I know I can use "os.system()" to invoke system calls, but I don't
> > So what is an easy one-liner way to store stdout of a sytem-call to a
> > variable?
> thevar = os.popen('ls *.txt | grep -v old | wc -l').read()
More information about the Python-list