os.system question

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Tue Aug 12 18:58:22 EDT 2008


On Mon, 11 Aug 2008 19:28:13 -0700, Asun Friere wrote:

> Something like this should work,
> 
>>>> from subprocess import Popen, PIPE
>>>> me = Popen('whoami', stdout=PIPE, shell=True).stdout.read()
> 
> but if I was in a hurry to find out who I was I would be tempted still
> to use the deprecated "os.popen('whoami').read()".

Is it really deprecated? Since when? I'm using Python 2.5 and it doesn't 
raise any warnings or mention anything in the doc string.

The current documentation does say:

"The subprocess module provides more powerful facilities for spawning new 
processes and retrieving their results; using that module is preferable 
to using this function."

http://docs.python.org/lib/os-newstreams.html#os-newstreams


but that's not the same as deprecating os.popen.



-- 
Steven



More information about the Python-list mailing list