Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

8
  • 35
    -1. The whole point of using shutil.rmdir is to insulate you from the type of operating system. Commented Dec 22, 2010 at 8:32
  • 4
    I understand the concept, but when one is well aware about the fact that (s)he want to delete the folder entirely, then what's the point of crawling the entire file tree ? shutil.rmdir specifically call os.listdir(), os.path.islink() etc etc.. some checks which are not really always needed, as all needed is to unlink the file system node. Beside on some build systems, like MSWindows for MSAuto/WinCE development, then shtuil.rmdir will fail almost always, as MSAuto batch based development locks some wierd build files on unsuccessful exit, and only rmdir /S/Q or restart is helpful to clean them. Commented Dec 23, 2010 at 8:10
  • 2
    yep, just rm is closer to kernel, using less time, memory and cpu ..... and as i said, the reason for me to use this method was because of locks left behind by MSAuto batch build scripts ... Commented Feb 11, 2012 at 18:25
  • 3
    Yes, but using shutil makes the code cross-platform and abstracts away platform details. Commented Aug 3, 2013 at 2:23
  • 2
    I do not think this answer should be down voted below 1 as it provides a very nice reference for a work around for certain situations in which a reader might be interested in. I enjoy having multiple methods posted with them ranked in order. So even though I do not need to use this I now know it can be done and how. Commented Jun 6, 2014 at 11:45