[Python-checkins] cpython (merge 3.4 -> 3.5): Docs for issue #22570. (Merge 3.4->3.5)

guido.van.rossum python-checkins at python.org
Wed Jan 6 14:38:35 EST 2016


https://hg.python.org/cpython/rev/408f8b255b56
changeset:   99785:408f8b255b56
branch:      3.5
parent:      99782:9c49c417a68a
parent:      99784:2e3c31ab586a
user:        Guido van Rossum <guido at python.org>
date:        Wed Jan 06 11:16:28 2016 -0800
summary:
  Docs for issue #22570. (Merge 3.4->3.5)

files:
  Doc/library/pathlib.rst |  17 +++++++++++++++++
  1 files changed, 17 insertions(+), 0 deletions(-)


diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst
--- a/Doc/library/pathlib.rst
+++ b/Doc/library/pathlib.rst
@@ -365,6 +365,23 @@
       ''
 
 
+.. 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::

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list