Rename file without overwriting existing files

Peter Otten __peter__ at
Mon Jan 30 09:38:12 EST 2017

Jon Ribbens wrote:

> On 2017-01-30, Peter Otten <__peter__ at> wrote:
>> Jon Ribbens wrote:
>>> A lot of the functions of the 'os' module do nothing but call the
>>> underlying OS system call with the same name. It would not only be
>>> redundant to copy the OS documentation into the Python documentation,
>>> it would be misleading and wrong, because of course the behaviour may
>>> vary slightly from OS to OS.
>> However, the current Python version of link() is sufficiently different
>> from
>><>, say, to warrant its own documentation.
> What are you referring to here? As far as I can see, the current
> Python implementation of link() just calls the underlying OS call
> directly.

The current signature differs from that of link(), dst, *, src_dir_fd=None, dst_dir_fd=None, follow_symlinks=True)

but it looks like you are right in so far as link() is still called by 

    if ((src_dir_fd != DEFAULT_DIR_FD) ||
        (dst_dir_fd != DEFAULT_DIR_FD) ||
        result = linkat(src_dir_fd, src->narrow,
            dst_dir_fd, dst->narrow,
            follow_symlinks ? AT_SYMLINK_FOLLOW : 0);
#endif /* HAVE_LINKAT */
        result = link(src->narrow, dst->narrow);

More information about the Python-list mailing list