Survey -- Move To Trash function in Python?

Chris Angelico rosuav at gmail.com
Thu May 14 22:56:17 EDT 2015


On Fri, May 15, 2015 at 12:49 PM, Ian Kelly <ian.g.kelly at gmail.com> wrote:
> On May 14, 2015 7:55 PM, "Chris Angelico" <rosuav at gmail.com> wrote:
>> (Though when
>> it comes to the bikeshedding phase, I'm sure there'll be some who say
>> "if it can't be trashed, just hard delete it", and others who say "if
>> it can't be trashed, raise an exception". And neither is truly wrong.)
>
> The answer is "raise an exception". Moving to trash and deleting are
> different operations, and one shouldn't be substituted for the other any
> more than a failed attempt to create a hard link should create a soft link
> instead.
>
> If the user wants, they can catch the exception and delete the file instead.
> Recovering from an accidental deletion would be more difficult.

Yes, but sometimes it's at the file system's discretion - particularly
when you're working with network mounts. The application may not even
know that the file got hard deleted.

ChrisA



More information about the Python-list mailing list