regarding system function

Robert Kern rkern at ucsd.edu
Fri Apr 22 03:45:11 EDT 2005


praba kar wrote:

> I agree above statement but When I delete a directory
> os.system('rm -rf test')
> 0
> if directory is not present then I again try to
> delete
> os.system('rm -rf test') 
> now this time also It will print
> 0

As Roman Neuhauser says, this is the correct behavior of the -f switch 
for rm.

In [4]:os.system('rm -r foo')
rm: foo: No such file or directory
Out[4]:256

In [5]:os.system('rm -rf foo')
Out[5]:0

-- 
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