Issue38499
Created on 2019-10-16 13:55 by valorien, last changed 2022-04-11 14:59 by admin. This issue is now closed.
| Messages (3) | |||
|---|---|---|---|
| msg354799 - (view) | Author: Alori (valorien) | Date: 2019-10-16 13:55 | |
pathlib.Path supports deletion of both files (Path.unlink()) and directories (Path.rmdir()). Unfortunately, Path.rmdir() does not allow deletion of non-empty directories which means users must use shutil.rmtree() when deleting such paths. Since pathlib.Path already supports file and (empty) directory deletion, adding Path.rmtree(missing_ok=False) would support both the utility and the completeness of pathlib. |
|||
| msg354805 - (view) | Author: Karthikeyan Singaravelan (xtreak) * ![]() |
Date: 2019-10-16 17:11 | |
There is shutil.rmtree that accepts path objects and is more high level. From the previous discussions with respect to expanding API it's recommended to change the functions already present to accept path objects which shutil.rmtree already does and not to expand pathlib API. Some related discussions : * https://mail.python.org/pipermail/python-ideas/2015-June/034236.html * https://mail.python.org/pipermail/python-dev/2016-April/143866.html |
|||
| msg354806 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2019-10-16 17:21 | |
Concur with Karthikeyan. pathlib.Path provides an object oriented interface to file path operations and to low-level filesystem operations. rmtree() is a high-level and complex operation. Instead of adding more and more complex operations to the Path class we added support of Path (and more generally, path-like objects) in many other functions. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:21 | admin | set | github: 82680 |
| 2019-10-16 17:21:17 | serhiy.storchaka | set | status: open -> closed superseder: pathlib.Path wants an rmtree method messages: + msg354806 resolution: duplicate |
| 2019-10-16 17:11:11 | xtreak | set | nosy:
+ serhiy.storchaka, xtreak, pitrou messages: + msg354805 |
| 2019-10-16 13:55:57 | valorien | create | |
