Add support for removedirs function

As makedirs() is implemented it sounds reasonable to also implement the related removedirs() function. rmtree() seems to be in place as an alternative but if I'm not mistaken the result is slightly different.

ftputiluser (unverified)
Assigned to
3 years ago
3 years ago
enhancement library

schwa (unverified) 3 years ago · edit

Thanks for your report!

For reference, here are the relevant sections from the documentation:

It looks to me that removedirs can be implemented by calling rmtree on the top-level directory with ignore_errors=True. Do you agree?

This doesn't add the functionality of accepting path-like objects though. This is the subject of ticket #119.

ftputiluser (unverified) 3 years ago · edit

Thanks for adding the relevant links, I should have done that myself...

I'm no expert on python or in those functions but judging from the documentation I would assume that rmtree differs in the following way:

  1. It also removes non-empty folders
  2. It tries to remove the whole path and not partially some sub directories.
  3. Exceptions were different and thrown in different cases I believe

I can be wrong in some or all points but that needs to be checked :)

Thanks for your great work!

Register here or Log in to comment, or comment via email.