From 003dd99066df0b1de723bf720a8f0ec74bad0a49 Mon Sep 17 00:00:00 2001 From: qiang_liu Date: Tue, 4 Nov 2025 20:52:09 +0800 Subject: [PATCH] gh-140971: Doc: Clarify pathlib.Path("") behavior --- Doc/library/pathlib.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst index 79e0b7f09eaa77..b30cd22eef7723 100644 --- a/Doc/library/pathlib.rst +++ b/Doc/library/pathlib.rst @@ -136,6 +136,14 @@ we also call *flavours*: >>> PurePath() PurePosixPath('.') + An empty string in *pathsegments* also refers to the current directory. + This means that ``PurePath("")`` is equivalent to ``PurePath(".")``, + and consequently ``Path("").exists()`` will always return ``True``. This + differs from ``os.path.exists("")``, which returns ``False``. + + >>> PurePath("") + PurePosixPath('.') + If a segment is an absolute path, all previous segments are ignored (like :func:`os.path.join`)::