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

Markus Unterwaditzer markus at unterwaditzer.net
Thu Jan 1 13:47:15 CET 2015


On Thu, Jan 01, 2015 at 11:35:26PM +1100, Steven D'Aprano wrote:
> On Thu, Jan 01, 2015 at 12:37:55PM +0200, Ram Rachum wrote:
> 
> > So maybe we can add a function to the `os` module that sends a file to the
> > recycle bin, and a constant that will say whether the current OS supports
> > this? Then we could have code like this:
> 
> The os module is for low-level operating-system functions. "Send to 
> trash" is neither low-level nor part of the OS per se, it is part of the 
> desktop environment.
> 
> I'm not convinced that this needs to be in the standard library, but if 
> it is, I think that the os module is completely the wrong place for it. 
> I think, in order of preference:
> 
> 1) shutil
> 2) pathlib
> 
> is the right place. 

Maybe the right way to do this is to create a new module, stdlib or not, for
desktop-related APIs. Besides a `recycle` function this might, for example,
include a subset of pyxdg's functionality.

-- Markus


More information about the Python-ideas mailing list