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

Greg Ewing greg.ewing at canterbury.ac.nz
Tue Dec 30 00:19:03 CET 2014


Andrew Barnert wrote:
> you just look up the name of the trash directory (which I believe
> is theoretically localized but actually always ~/.Trash on the drive with
> your user directory, $mnt/.Trash otherwise) and call rename.

You may also need to invent a unique name if there's already
a file in the trash with the same name.

> And I don't know what the right thing to do on OS X would be for a file on a
> different filesystem than the user's home that doesn't have its own .Trash or
> is mounted read-only or no-trash.

Raising an exception would seem to be a reasonable thing to
do in that case.

-- 
Greg


More information about the Python-ideas mailing list