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.

Given this context it's pretty clear that the OP wants a way to use
shutil.copy2(src, dst, follow_symlinks=False), which preserves symlinks (if
supported by the platform). Unfortunately we can't just add a new parameter
follow_symlinks=True to shutil.move(), since that would break all existing
code that passes a function of exactly two arguments.

The OP's problem is easily solved using a lambda though:

shutil.move(src, dst, lambda s, d: shutil.copy2(s, d,
follow_symlinks=False))

On Thu, Dec 19, 2019 at 12:27 PM Steven D'Aprano <st...@pearwood.info>
wrote:

> On Wed, Dec 18, 2019 at 01:48:22PM -0000, Namjun Kim wrote:
> > I think shutil.move method should provide a symlinks parameter.
>
> What will it do? What behaviour will it change? Please be precise: what
> values does the parameter take, what is the default (if any), what
> effect does it have.
>
> You have probably been thinking hard about this for a while, but we
> haven't been, and what might be obvious to you may not be obvious to
> everyone. It certainly isn't obvious to me.
>
> If I were going to guess what this did, I'd guess that it did the same
> thing as the symlink option to the Unix 'mv' command, except that the
> 'mv' command doesn't have a symlink paramater.
>
>
>
> --
> Steven
> _______________________________________________
> Python-ideas mailing list -- python-ideas@python.org
> To unsubscribe send an email to python-ideas-le...@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-ideas@python.org/message/E5QTNJYZLMMSDVZLJWAIZBULW5QB2CTG/
> Code of Conduct: http://python.org/psf/codeofconduct/
>


-- 
--Guido van Rossum (python.org/~guido)
*Pronouns: he/him **(why is my pronoun here?)*
<http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/CETVUZX7HKMJUE7JZ2VMZPQC4IQXJHDA/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to