Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit df85946

Browse files
committed
Docs for issue #22570.
1 parent e428231 commit df85946

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Doc/library/pathlib.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,23 @@ Pure paths provide the following methods and properties:
365365
''
366366

367367

368+
.. data:: PurePath.path
369+
370+
A string representing the full path::
371+
372+
>>> PurePosixPath('my/library/setup.py').path
373+
'my/library/setup.py'
374+
375+
This always returns the same value as ``str(p)``; it is included to
376+
serve as a one-off protocol. Code that wants to support both
377+
strings and ``pathlib.Path`` objects as filenames can write
378+
``arg = getattr(arg, 'path', arg)`` to get the path as a string.
379+
This can then be passed to various system calls or library
380+
functions that expect a string. Unlike the alternative
381+
``arg = str(arg)``, this will still raise an exception if an object
382+
of some other type is given by accident.
383+
384+
368385
.. data:: PurePath.suffix
369386

370387
The file extension of the final component, if any::

0 commit comments

Comments
 (0)