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

Chris Angelico rosuav at gmail.com
Sat Jan 3 11:39:46 CET 2015

On Sat, Jan 3, 2015 at 9:28 PM, Andrew Barnert <abarnert at yahoo.com> wrote:
> The Mac version also does the move-to-trash; it has perfectly acceptable performance.

Good. The note about performance was a mere parenthesis, and the last
time I did anything like that on Windows was on XP, so it's quite
possibly different on Win7/8.

> I agree with this, but it still might be nice to mention that third-party module in shutil and/or pathlib.

Maybe. Is there a mention of other third-party packages in stdlib
docs? It's a slippery slope; which ones deserve mention? Maybe just
something like "Note that moving objects to the trash can is possible
in OS-dependent ways; packages are available on PyPI to make this
easier", without naming any.

> Honestly, I think one of the big things people want is the ability to write the "trash" tool for use on the command line that all of the major desktop systems are missing. It feels like it should be a 3-line Python script, and the fact that it isn't possible looks like a weakness. But really, I don't think that's a problem. OS X comes with a Python with PyObjC; a GNOME or KDE system can install python-gobject or PySide in one apt-get/urpmi/port/etc. command; Windows' function is accessible via the built-in ctypes. I have such scripts on my Mac and Fedora boxes; the fact that they're _different_ 3-line scripts is hardly a serious problem.

As an explicit "trash" tool, sure. Typing "trash some_file" is under
human control just as much as hitting Delete without holding Shift is.
I just don't think it should be the obvious way for an application to
remove files.


More information about the Python-ideas mailing list