Skip to content

GH-73991: Add pathlib.Path.copy_into() and move_into() #123314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 26, 2024

Conversation

barneygale
Copy link
Contributor

@barneygale barneygale 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.
@barneygale barneygale merged commit c68a93c into python:main Aug 26, 2024
34 checks passed
Sign up for free to 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