summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2016-01-06 19:15:52 (GMT)
committerGuido van Rossum <guido@python.org>2016-01-06 19:15:52 (GMT)
commitdf85946e8a5586b6dc4f242d7fa24ea04a2044f8 (patch)
tree05bdc7e0bd4885efab8b9f80adedf6dc74fb61e2
parente42823153990ab5a4bb5f9148458cf48e189f4f9 (diff)
downloadcpython-df85946e8a5586b6dc4f242d7fa24ea04a2044f8.zip
cpython-df85946e8a5586b6dc4f242d7fa24ea04a2044f8.tar.gz
cpython-df85946e8a5586b6dc4f242d7fa24ea04a2044f8.tar.bz2
Docs for issue #22570.
-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 24e2a30..05c5d72 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::