summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2016-01-06 19:16:28 (GMT)
committerGuido van Rossum <guido@python.org>2016-01-06 19:16:28 (GMT)
commit406005144ba0ade4702f439a8f56d6c3c1332a15 (patch)
treefa27ce8fcf542cebf867373f5e5269584a081d71 /Doc
parent1a4afec0d66d8843834250836d1056ed6d687385 (diff)
parentdf85946e8a5586b6dc4f242d7fa24ea04a2044f8 (diff)
downloadcpython-406005144ba0ade4702f439a8f56d6c3c1332a15.zip
cpython-406005144ba0ade4702f439a8f56d6c3c1332a15.tar.gz
cpython-406005144ba0ade4702f439a8f56d6c3c1332a15.tar.bz2
Docs for issue #22570. (Merge 3.4->3.5)
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/pathlib.rst17
1 files changed, 17 insertions, 0 deletions
diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst
index 2f06544..29298c7 100644
--- a/Doc/library/pathlib.rst
+++ b/Doc/library/pathlib.rst
@@ -365,6 +365,23 @@ Pure paths provide the following methods and properties:
''
+.. data:: PurePath.path
+
+ A string representing the full path::
+
+ >>> PurePosixPath('my/library/setup.py').path
+ 'my/library/setup.py'
+
+ This always returns the same value as ``str(p)``; it is included to
+ serve as a one-off protocol. Code that wants to support both
+ strings and ``pathlib.Path`` objects as filenames can write
+ ``arg = getattr(arg, 'path', arg)`` to get the path as a string.
+ This can then be passed to various system calls or library
+ functions that expect a string. Unlike the alternative
+ ``arg = str(arg)``, this will still raise an exception if an object
+ of some other type is given by accident.
+
+
.. data:: PurePath.suffix
The file extension of the final component, if any::