[Tutor] removedirs ?
orion_val at 163.com
Fri Dec 17 02:16:11 CET 2004
Of course, shutil.rmtree() is a fast and direct method, but still a
little warning, it could be dangerous. No warning and ensure will be
raised while removing a tree of files.
Kent Johnson wrote:
> You misunderstand what removedirs does. It removes an empty directory;
> then, if the removed directory's parent is now empty, it removes that,
> too, and so on until it finds a directory with something in it or gets
> up to the root.
> Try shutil.rmtree() or this recipe:
> Ertl, John wrote:
>> I am trying to remove a directory that has other directories and
>> files in
>> it. I thought removedirs was supposed to do a recursive remove of
>> files and
>> When I try it I get
>> Traceback (most recent call last):
>> File "<pyshell#11>", line 1, in -toplevel-
>> File "/home/ertlj/ertljVersion/lib/python2.3/os.py", line 167, in
>> OSError: [Errno 17] File exists: 'DAF'
>> John Ertl
> Tutor maillist - Tutor at python.org
More information about the Tutor