Skip to content

gh-140971: Document pathlib.PurePath("") meaning and bool value - #157293

Open
terryjreedy wants to merge 3 commits into
python:mainfrom
terryjreedy:emptypathdoc
Open

terryjreedy wants to merge 3 commits into
python:mainfrom
terryjreedy:emptypathdoc

Conversation

@terryjreedy

@terryjreedy terryjreedy commented Sep 11, 2026

Copy link
Copy Markdown
Member

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

pathlib.PurePath() and pathlib.PurePath('') both mean the
current working directory and both have boolean value True.

Patch implements suggestion in
python#140993 (comment).
---

Co-authored-by: LiuQhahah <liuqiang9596@gmail.com>
@terryjreedy

Copy link
Copy Markdown
Member Author

@StanFromIreland Please check that co-author note is correct. Add to commit message if too terse.

@read-the-docs-community

read-the-docs-community Bot commented Sep 11, 2026

Copy link
Copy Markdown

@terryjreedy terryjreedy added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Sep 11, 2026

@StanFromIreland StanFromIreland left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, this slipped my mind.

Comment thread Doc/library/pathlib.rst Outdated
Comment thread Doc/library/pathlib.rst Outdated
(PurePosixPath('.'), PurePosixPath('.'))

The boolean value of either expression is True.
This differs from ``os.path.exists("")``, which returns ``False``.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This differs from ``os.path.exists("")``, which returns ``False``.
Because ``Path('')`` refers to the current directory, ``Path('').exists()``
returns ``True``, unlike :func:`os.path.exists`, which returns ``False``
for an empty string.

Actually, I think this would be better placed in the .exists() documentation?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a shorter sentence to the 'exists' entry. Please review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review docs Documentation in the Doc dir needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants