From: Guido van Rossum Date: Wed, 6 Jan 2016 19:15:52 +0000 (-0800) Subject: Docs for issue #22570. X-Git-Tag: v3.4.5rc1~36 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=df85946e8a5586b6dc4f242d7fa24ea04a2044f8;p=thirdparty%2FPython%2Fcpython.git Docs for issue #22570. --- diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst index 24e2a308dfe2..05c5d722ef7d 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::