changeset: 99784:2e3c31ab586a branch: 3.4 parent: 99781:7e9605697dfc user: Guido van Rossum date: Wed Jan 06 11:15:52 2016 -0800 files: Doc/library/pathlib.rst description: Docs for issue #22570. diff -r 7e9605697dfc -r 2e3c31ab586a Doc/library/pathlib.rst --- a/Doc/library/pathlib.rst Wed Jan 06 11:01:42 2016 -0800 +++ b/Doc/library/pathlib.rst Wed Jan 06 11:15:52 2016 -0800 @@ -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::