Skip to content

Commit 6eee976

Browse files
gh-140971: Document pathlib.PurePath("") meaning and bool value
pathlib.PurePath() and pathlib.PurePath('') both mean the current working directory and both have boolean value True. Patch implements suggestion in #140993 (comment). --- Co-authored-by: LiuQhahah <liuqiang9596@gmail.com>
1 parent 8f84787 commit 6eee976

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

Doc/library/pathlib.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,14 @@ we also call *flavours*:
131131
>>> PurePath(Path('foo'), Path('bar'))
132132
PurePosixPath('foo/bar')
133133

134-
When *pathsegments* is empty, the current directory is assumed::
134+
When *pathsegments* is empty or a single empty string,
135+
the current directory is assumed::
135136

136-
>>> PurePath()
137-
PurePosixPath('.')
137+
>>> PurePath(), PurePath('')
138+
(PurePosixPath('.'), PurePosixPath('.'))
139+
140+
The boolean value of either expression is True.
141+
This differs from ``os.path.exists("")``, which returns ``False``.
138142

139143
If a segment is an absolute path, all previous segments are ignored
140144
(like :func:`os.path.join`)::

0 commit comments

Comments
 (0)