Well, I should have read the source instead of the docs. :-( Contrary to
what I thought, move() always preserves symlinks.

Let's stop second-guessing until the OP responds.

On Fri, Dec 20, 2019 at 11:43 Random832 <[email protected]> wrote:

> On Thu, Dec 19, 2019, at 17:43, Guido van Rossum wrote:
> > A quick look at the docs
> > <https://docs.python.org/3/library/shutil.html#shutil.move> shows what
> > the OP is likely after.
> >
> > The function has this signature:
> >
> > `shutil.``move`(*src*, *dst*, *copy_function=copy2*)ΒΆ
> > <https://docs.python.org/3/library/shutil.html#shutil.move>
> >
> > The copy_function argument is a function of two parameters (src and
> > dst) which is called *when os.rename() cannot be used*. (E>g. for
> > cross-filesystem moves.) In that case the individual files are copied
> > using copy_function(src, dst). The default copy_function is
> > shutil.copy2
> > <https://docs.python.org/3/library/shutil.html#shutil.copy2>, which
> > defaults to follow_symlinks=True, i.e. it doesn't recognize symlinks
> > and instead copies the contents.
>
> except the line highlighted in the OP link was where it passes
> symlinks=True to copytree, whose usage is not parameterized at all.
> copy_function isn't therefore, to my understanding, going to be called on
> symlinks in that case, only regular files.
>
> This is why some of us are confused as to what the OP wants - copytree is
> only called if rename fails, so making it behave differently on symlinks
> will mean that symlinks in the original tree behave one way when moving
> within a filesystem, and a different way when moving to a different
> filesystem.
> _______________________________________________
> Python-ideas mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at
> https://mail.python.org/archives/list/[email protected]/message/B2YT6K4QLSPD2KTVPFHBR53YBI46KZTJ/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-- 
--Guido (mobile)
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/TAAAELT47YEHELQORUUI7GQFQTIQJKVW/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to