summaryrefslogtreecommitdiffstats
path: root/Doc/library/pathlib.rst
diff options
context:
space:
mode:
authorLarry Hastings <larry@hastings.org>2014-03-16 04:13:56 (GMT)
committerLarry Hastings <larry@hastings.org>2014-03-16 04:13:56 (GMT)
commit3732ed24145c1ac77e99bcf85bccda3af095e696 (patch)
tree432a243f5f4d9720ec0cc202ee969f6175e450b7 /Doc/library/pathlib.rst
parentb6b6a6d587d267cbad490232d08faebd30fdb7e2 (diff)
downloadcpython-3732ed24145c1ac77e99bcf85bccda3af095e696.zip
cpython-3732ed24145c1ac77e99bcf85bccda3af095e696.tar.gz
cpython-3732ed24145c1ac77e99bcf85bccda3af095e696.tar.bz2
Merge in all documentation changes since branching 3.4.0rc1.
Diffstat (limited to 'Doc/library/pathlib.rst')
-rw-r--r--Doc/library/pathlib.rst30
1 files changed, 30 insertions, 0 deletions
diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst
index 3aa9d4b..ec1dc4f 100644
--- a/Doc/library/pathlib.rst
+++ b/Doc/library/pathlib.rst
@@ -522,6 +522,36 @@ Pure paths provide the following methods and properties:
ValueError: '/etc/passwd' does not start with '/usr'
+.. method:: PurePath.with_name(name)
+
+ Return a new path with the :attr:`name` changed. If the original path
+ doesn't have a name, ValueError is raised::
+
+ >>> p = PureWindowsPath('c:/Downloads/pathlib.tar.gz')
+ >>> p.with_name('setup.py')
+ PureWindowsPath('c:/Downloads/setup.py')
+ >>> p = PureWindowsPath('c:/')
+ >>> p.with_name('setup.py')
+ Traceback (most recent call last):
+ File "<stdin>", line 1, in <module>
+ File "/home/antoine/cpython/default/Lib/pathlib.py", line 751, in with_name
+ raise ValueError("%r has an empty name" % (self,))
+ ValueError: PureWindowsPath('c:/') has an empty name
+
+
+.. method:: PurePath.with_suffix(suffix)
+
+ Return a new path with the :attr:`suffix` changed. If the original path
+ doesn't have a suffix, the new *suffix* is appended instead::
+
+ >>> p = PureWindowsPath('c:/Downloads/pathlib.tar.gz')
+ >>> p.with_suffix('.bz2')
+ PureWindowsPath('c:/Downloads/pathlib.tar.bz2')
+ >>> p = PureWindowsPath('README')
+ >>> p.with_suffix('.txt')
+ PureWindowsPath('README.txt')
+
+
.. _concrete-paths: