[Python-ideas] Adding `pathlib.Path` method that would send file to recycle bin

Steven D'Aprano steve at pearwood.info
Fri Jan 2 01:09:14 CET 2015

On Thu, Jan 01, 2015 at 02:43:09PM +0200, Ram Rachum wrote:

> Regarding your question: "But I'm still not sure that this needs to be in
> the standard library. For such a specialist need, what's wrong with using a
> third party solution?"
> Well, I can use a third-party solution for everything, but it would be
> nicer for me if it was in the standard library because then I could count
> on it always being there and the API not changing.

Which is exactly the point. It has been said that the standard library 
is where good modules go to die. Do you think that the "move to trash" 
API is ready to die? I don't think so. I think that there is a lot more 
than just moving files to the trash.

I've spent a little bit of time over the last day or so thinking about 
what sort of trash-related functionality I would like, as a Linux user:

- move to trash, of course, but which trash?
- return the name of the trash directory in my home directory
- list trash directories on other partitions and disks
- list trash directories for all users (if I have read permission)
- empty one or more of those trash directories
- optionally only deleting sufficiently old and/or large files
- validate and/or repair the trash metadata
- report how much space is used by the trash, with or without metadata
- support legacy .Trash directories as well as .local/share/Trash

For some operations, I would want to specify either a specific trash 
directory, or all trash directories for a given user (defaulting to the 
current user), or all trash directories for all users. (The later would 
only work if I was running as the root/Administrator user, of course.)

The point being that the API for all this functionality isn't obvious, 
and it is very unlikely to be so stable that it is ready to move into 
the standard library.


More information about the Python-ideas mailing list