Skip to content

Conversation

@barneygale
Copy link
Contributor

@barneygalebarneygale commented Aug 25, 2024

These two methods accept an existing directory path, onto which we join the source path's base name to form the final target path.

A possible alternative implementation is to check for directories in copy() and move() and adjust the target path, which is done in several shutil functions. This behaviour is helpful in a shell context, but less so in a stored program that explicitly specifies destinations. For example, a user that calls Path('foo.py').copy('bar.py') might not imagine that bar.py/foo.py would be created, but under the alternative implementation this will happen if bar.py is an existing directory.


📚 Documentation preview 📚: https://cpython-previews--123314.org.readthedocs.build/

These two methods accept an *existing* directory path, onto which we join the source path's base name to form the final target path. A possible alternative implementation is to check for directories in `copy()` and `move()` and adjust the target path, which is done in several `shutil` functions. This behaviour is helpful in a shell context, but less so in a stored program that explicitly specifies destinations. For example, a user that calls `Path('foo.py').copy('bar.py')` might not imagine that `bar.py/foo.py` would be created, but under the alternative implementation this will happen if `bar.py` is an existing directory.
@barneygalebarneygale merged commit c68a93c into python:mainAug 26, 2024
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@barneygale@pfmoore