<div dir="ltr">I take your point about it not being in the `os` module, I have no issue with it being in shutil or pathlib.<div><br></div><div>I also agree about the name, "recycle" doesn't really make sense. </div><div><br></div><div>Regarding your question: "But I'm still not sure that this needs to be in the standard library. For such a specialist need, what's wrong with using a third party solution?"</div><div><br></div><div>Well, I can use a third-party solution for everything, but it would be nicer for me if it was in the standard library because then I could count on it always being there and the API not changing. I could say the same thing you said about the `webbrowser` module, that opening a new browser tab is quite a specialist need, but I do enjoy having it available in the standard library and I feel the same about sending a file to trash, which I think is a basic feature that's we've all been taking for granted for the last decade or two. </div><div><br></div><div><br></div><div>Happy new year,</div><div>Ram.<br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 1, 2015 at 2:35 PM, Steven D'Aprano <span dir="ltr"><<a href="mailto:steve@pearwood.info" target="_blank" onclick="window.open('https://mail.google.com/mail/?view=cm&tf=1&to=steve@pearwood.info&cc=&bcc=&su=&body=','_blank');return false;">steve@pearwood.info</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">On Thu, Jan 01, 2015 at 12:37:55PM +0200, Ram Rachum wrote:<br>
<br>
> So maybe we can add a function to the `os` module that sends a file to the<br>
> recycle bin, and a constant that will say whether the current OS supports<br>
> this? Then we could have code like this:<br>
<br>
</span>The os module is for low-level operating-system functions. "Send to<br>
trash" is neither low-level nor part of the OS per se, it is part of the<br>
desktop environment.<br>
<br>
I'm not convinced that this needs to be in the standard library, but if<br>
it is, I think that the os module is completely the wrong place for it.<br>
I think, in order of preference:<br>
<br>
1) shutil<br>
2) pathlib<br>
<br>
is the right place.<br>
<br>
(The actual implementation for the move_to_trash function could come<br>
from another, platform-specific, module.)<br>
<span class=""><br>
<br>
> if os.RECYCLE_BIN_SUPPORT:<br>
>     os.recycle(my_file)<br>
> else:<br>
>     os.remove(my_file)<br>
<br>
<br>
</span>"Recycle" is not a good name for the function, because it doesn't<br>
recycle the file. It does the opposite of recycle: it prevents the file<br>
from being deleted and over-written. I think an explicit name like<br>
move_to_trash is better than something misleading like "recycle".<br>
<br>
No need for a special flag to check if the function exists, just check<br>
for the function:<br>
<br>
try:<br>
    f = shutil.send_to_trash<br>
except AttributeError:<br>
    f = os.remove<br>
f(my_file)<br>
<br>
<br>
But I'm still not sure that this needs to be in the standard library.<br>
For such a specialist need, what's wrong with using a third party<br>
solution?<br>
<div class=""><div class="h5"><br>
<br>
--<br>
Steven<br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" onclick="window.open('https://mail.google.com/mail/?view=cm&tf=1&to=Python-ideas@python.org&cc=&bcc=&su=&body=','_blank');return false;">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</div></div></blockquote></div><br></div></div></div>