[issue12741] Add function similar to shutil.move that does not overwrite

David Townshend report at bugs.python.org
Sun Aug 14 08:01:03 CEST 2011


David Townshend <aquavitae69 at gmail.com> added the comment:

A bit of research has shown that the proposed implementation will not work either, so my next suggestion is something along the lines of

def move2(src, dst):
    try:
        os.link(src, dst)
    except OSError as err:
        # handle error appropriately, raise shutil.Error if dst exists,
        # or use shutil.copy2 if dst is on a different filesystem.
        pass
    else:
        os.unlink(src)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12741>
_______________________________________


More information about the Python-bugs-list mailing list