summaryrefslogtreecommitdiffstats
path: root/Doc/library/pathlib.rst
diff options
context:
space:
mode:
authorhui shang <shangdahao@gmail.com>2019-09-11 13:26:49 (GMT)
committerJason R. Coombs <jaraco@jaraco.com>2019-09-11 13:26:49 (GMT)
commit088a09af4bdeff52b9dedeb7acd1e82069f37d98 (patch)
tree26aaebe83ddd99faa504ca67e8a97c1b8e4d5263 /Doc/library/pathlib.rst
parentf9b5840fb4497a9e2ba2c1f01ad0dafba04c8496 (diff)
downloadcpython-088a09af4bdeff52b9dedeb7acd1e82069f37d98.zip
cpython-088a09af4bdeff52b9dedeb7acd1e82069f37d98.tar.gz
cpython-088a09af4bdeff52b9dedeb7acd1e82069f37d98.tar.bz2
bpo-31163: Added return values to pathlib.Path instance's rename and replace methods. (GH-13582)
* bpo-31163: Added return values to pathlib.Path instance's rename and replace methods.
Diffstat (limited to 'Doc/library/pathlib.rst')
-rw-r--r--Doc/library/pathlib.rst19
1 files changed, 14 insertions, 5 deletions
diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst
index 33fac5f..d33e2d0 100644
--- a/Doc/library/pathlib.rst
+++ b/Doc/library/pathlib.rst
@@ -946,23 +946,32 @@ call fails (for example because the path doesn't exist).
.. method:: Path.rename(target)
- Rename this file or directory to the given *target*. On Unix, if
- *target* exists and is a file, it will be replaced silently if the user
- has permission. *target* can be either a string or another path object::
+ Rename this file or directory to the given *target*, and return a new Path
+ instance pointing to *target*. On Unix, if *target* exists and is a file,
+ it will be replaced silently if the user has permission. *target* can be
+ either a string or another path object::
>>> p = Path('foo')
>>> p.open('w').write('some text')
9
>>> target = Path('bar')
>>> p.rename(target)
+ PosixPath('bar')
>>> target.open().read()
'some text'
+ .. versionchanged:: 3.8
+ Added return value, return the new Path instance.
+
.. method:: Path.replace(target)
- Rename this file or directory to the given *target*. If *target* points
- to an existing file or directory, it will be unconditionally replaced.
+ Rename this file or directory to the given *target*, and return a new Path
+ instance pointing to *target*. If *target* points to an existing file or
+ directory, it will be unconditionally replaced.
+
+ .. versionchanged:: 3.8
+ Added return value, return the new Path instance.
.. method:: Path.resolve(strict=False)