From 6eee97667dbb251d84b403bee4da8adaee9be807 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Thu, 10 Sep 2026 20:41:44 -0400 Subject: [PATCH] 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 https://github.com/python/cpython/pull/140993#discussion_r2490858118. --- Co-authored-by: LiuQhahah --- Doc/library/pathlib.rst | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst index ab92c142c37a4f6..1f28f217b83b217 100644 --- a/Doc/library/pathlib.rst +++ b/Doc/library/pathlib.rst @@ -131,10 +131,14 @@ we also call *flavours*: >>> PurePath(Path('foo'), Path('bar')) PurePosixPath('foo/bar') - When *pathsegments* is empty, the current directory is assumed:: + When *pathsegments* is empty or a single empty string, + the current directory is assumed:: - >>> PurePath() - PurePosixPath('.') + >>> PurePath(), PurePath('') + (PurePosixPath('.'), PurePosixPath('.')) + + The boolean value of either expression is True. + This differs from ``os.path.exists("")``, which returns ``False``. If a segment is an absolute path, all previous segments are ignored (like :func:`os.path.join`)::