os.system(r"ls") prints to screen??

Robert Kern rkern at ucsd.edu
Sat Sep 3 21:21:07 EDT 2005


Xah Lee wrote:
> does anyone know why the folllowing prints to the screen?
> 
> # python
> import os
> os.system(r"ls")

os.system() starts a shell and has the shell execute the program as a
separate process. If you want to get the output of the given program,
then use the subprocess module.

-- 
Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter




More information about the Python-list mailing list