Skip to content

Commit 003dd99

Browse files
committed
gh-140971: Doc: Clarify pathlib.Path("") behavior
1 parent fa9c3ee commit 003dd99

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Doc/library/pathlib.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@ we also call *flavours*:
136136
>>> PurePath()
137137
PurePosixPath('.')
138138

139+
An empty string in *pathsegments* also refers to the current directory.
140+
This means that ``PurePath("")`` is equivalent to ``PurePath(".")``,
141+
and consequently ``Path("").exists()`` will always return ``True``. This
142+
differs from ``os.path.exists("")``, which returns ``False``.
143+
144+
>>> PurePath("")
145+
PurePosixPath('.')
146+
139147
If a segment is an absolute path, all previous segments are ignored
140148
(like :func:`os.path.join`)::
141149

0 commit comments

Comments
 (0)