[Python-ideas] shutil.trash()

Jonathan Eunice jonathan.eunice at gmail.com
Tue May 14 00:18:21 CEST 2013

Move-to-trash is a pretty common operation on Windows, Mac, and Linux (when 
configured for GUI use). Such user-facing OSs account for hundreds of 
millions or billions of systems. 

That move-to-trash seems an odd operation compared to `os` is probably more 
a reflection on how Unix-centric `os` is. `dup`, `dup2`, `chown`, and 
`execv`? They go back at least to 6th or 7th Edition Unix in the mid-1970s. 
The standard Python standard library should be able to express common 
operations, and updating it to accommodate more recent idioms than POSIX 
makes sense to me. `shutil` seems the natural home.

But practically speaking, `send2trash` doesn't seem complete enough to 
promote. It seems to use different implementations for Python 2 and 3. I 
didn't see an empty-trash API. It would need clear semantics in the case 
that "the trashcan" is not available (e.g. Linux without desktop extensions 
loaded). And testing is key. It would have to be robustly tested across 
Python versions and implementations, as well as different OSs, OS versions, 
and user environment frameworks, under both correct and error conditions. 
If it were all these things, I can see a natural path into `shutil`. Until 
then, PyPI is the natural home.

If the standard library could learn about the trash can, perhaps eventually 
it could learn about the clipboard!

On Saturday, April 6, 2013 6:25:54 PM UTC-4, Gregory P. Smith wrote:
> Is it widely used?
> I think it sounds useful for someone but is the kind of thing that should 
> be fine as an extension module on PyPI for most people's needs.  It seems 
> like the kind of functionality that would go along with a GUI library. 
>  Other software is unlikely to care about an OSes concept of trash and 
> simply rm/del/unlink things.
> otherwise, yes, shutil is a reasonable place if it were to be added.
> On Sat, Apr 6, 2013 at 8:21 AM, Virgil Dupras <hs... at hardcoded.net<javascript:>
> > wrote:
>> Hi all,
>> A while ago, I've developed this library, send2trash ( 
>> https://bitbucket.org/hsoft/**send2trash<https://bitbucket.org/hsoft/send2trash>), which can send files to trash on Mac OS X, Windows, and any platform 
>> that conforms to FreeDesktop.
>> The current version uses ctypes, but earlier versions were straight C 
>> modules.
>> I was wondering if you think this has a place in the stdlib, maybe as 
>> "shutil.trash()"?
>> Virgil Dupras
>> ______________________________**_________________
>> Python-ideas mailing list
>> Python... at python.org <javascript:>
>> http://mail.python.org/**mailman/listinfo/python-ideas<http://mail.python.org/mailman/listinfo/python-ideas>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130513/a2dc6639/attachment-0001.html>

More information about the Python-ideas mailing list