[Python-ideas] shutil.symlink to allow non-race replacement of existing link targets

Steven D'Aprano steve at pearwood.info
Tue May 14 09:29:01 EDT 2019


On Tue, May 14, 2019 at 10:26:28AM +0300, Serge Matveenko wrote:

> How about introducing `force=False` argument to
> `pathlib.Path.symlink_to` method?
> It looks like a good place for this as `pathlib` is actually the place
> where higher-level things to operate on paths live already 

I don't think we can say pathlib is the place for higher-level 
operations. It isn't what the os docs say:

https://docs.python.org/3/library/os.html

it explicitly says shutils is for higher-level path operations.

The beauty of shutil is that it can operate on pathnames whether 
they are strings, bytes or Path objects, and doesn't force you to 
use one or the other.


Aside: I'm not sure how much progress has been made on making Path 
objects fully usable by shutil. There's this open issue:

https://bugs.python.org/issue30235

so I think progress is being made but may not be complete.


-- 
Steven


More information about the Python-ideas mailing list