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

Ram Rachum ram at rachum.com
Thu Jan 1 11:37:55 CET 2015


Hi everyone,

I'm a complete ignoramus when it comes to Mac, so I can't say anything
about that, but as I understand the discussion, there are problems with
implementing this on Mac. Okay. So maybe this should be available only on
Windows and Linux? (If it's not a problem to do on Linux.) As much as I
don't like having functionality that's only available on certain OSs, it
makes more sense than depriving Windows users of functionality that they
could be using just because Mac doesn't support it. (And of course, Python
has lots of OS-specific modules.)

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:

if os.RECYCLE_BIN_SUPPORT:

    os.recycle(my_file)

else:

    os.remove(my_file)

What do you think?


Thanks,
Ram.

On Thu, Jan 1, 2015 at 1:14 AM, Steven D'Aprano <steve at pearwood.info> wrote:

> On Wed, Dec 31, 2014 at 11:50:04AM +0100, Andrew Barnert wrote:
> > On Dec 31, 2014, at 0:47, Steven D'Aprano <steve at pearwood.info> wrote:
>
> > > What's wrong with asking the Finder to move the file? Under what
> > > circumstances would that be unacceptable? Are there scenarios on OS X
> > > where the Finder isn't available but the trash is?
> >
> > I already answered this briefly earlier in the thread, but in more
> detail:
> [...]
>
> Thank you for the detailed and extensive answer!
>
>
> --
> Steven
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150101/2626e926/attachment.html>


More information about the Python-ideas mailing list