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

random832 at fastmail.us random832 at fastmail.us
Sun Jan 4 20:24:36 CET 2015

On Fri, Jan 2, 2015, at 20:50, Steven D'Aprano wrote:
> > Because what _not_ having a
> > cross-platform wrapper gets you is windows and mac left behind 
> Really? I would expect that Windows is probably the *easiest* platform 
> to implement this functionality, as it has a single, standard, stable 
> API for moving files to trash. (Or so I am lead to believe.) You can 
> probably use that API via ctypes, or via pywin32.

Why would someone who is developing on Linux and has no pre-made library
function to call bother with that?

If being cross-platform isn't easy, it won't happen. You see it now with
the lack of any support for "call glob on arguments on windows and not
on unix" [because the shell handles it on unix] whether directly, in
argparse, or in fileinput - today, nothing ever calls glob, and so
people calling such scripts on windows can't use wildcards (glob is also
different from windows wildcards in subtle ways)

> Getting OS X right is very complicated, as Andrew has so ably explained.
> In Linux and other Unixes, the situation is like OS X, only more so 
> since there's no one single authority.

However, what authority there is does not allegedly demand that you
present dialog boxes and admin elevation prompts to the user (this has
been asserted, but no citation has been given).

> You have a choice of desktop 
> environments, which may or may not provide a move-to-trash API, 
> including no desktop environment at all. Gnome provides an API for 
> moving to trash, but I don't know how well it supports the freedesktop 
> standard; KDE supports the freedesktop standard, but I don't know if it 
> provides an API that can be called. XFCE has partial support.

I don't see why you need to call an API to the desktop enviroment. The
entire point of the spec is to provide compatibility _between_
implementations on the same filesystem - you can quit gnome and log into
KDE and see the same trash. Python would just be a separate
implementation that stands by itself.

More information about the Python-ideas mailing list