Skip to content

a bit better example in pathlib docs - maybe include example path that involves file in a folder(s)? #120794

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
matkoniecz opened this issue Jun 20, 2024 · 4 comments
Labels
docs Documentation in the Doc dir topic-pathlib

Comments

@matkoniecz
Copy link

matkoniecz commented Jun 20, 2024

Documentation

See https://docs.python.org/3/library/pathlib.html#concrete-paths

Path('setup.py') and PosixPath('/etc') and WindowsPath('c:/Program Files/') both have single level only.

Would it be OK to have example with file in a folder? say PosixPath('/etc/hosts') (if that is correct way to pass more complex paths to constructor...)

Would PR changing this would be welcome and have chances to be reviewed?

Linked PRs

@matkoniecz matkoniecz added the docs Documentation in the Doc dir label Jun 20, 2024
@nineteendo
Copy link
Contributor

nineteendo commented Jun 20, 2024

Sure, also applies to pure paths: https://docs.python.org/3/library/pathlib.html#pure-paths, which is only seen in normalisation edge cases and unc paths.

@matkoniecz matkoniecz changed the title a biit better example in pathlib docs - maybe include example path that involves file in a folder(s)? a bit better example in pathlib docs - maybe include example path that involves file in a folder(s)? Jun 27, 2024
@barneygale
Copy link
Contributor

A few more examples wouldn't hurt, e.g. for PosixPath we could show:

>>> PosixPath('/etc/hosts')
PosixPath('/etc/hosts')
>>> PosixPath('/home', 'mat', '.profile')
PosixPath('/home/mat/.profile')

Happy to review a PR

barneygale added a commit to barneygale/cpython that referenced this issue Aug 10, 2024
In the documentation of `PosixPath` and `WindowsPath`, and their `Pure*`
equivalents, use example paths with multiple non-anchor parts.
barneygale added a commit that referenced this issue Aug 10, 2024
…2887)

In the documentation of `PosixPath` and `WindowsPath`, and their `Pure*`
equivalents, use example paths with multiple non-anchor parts.

Co-authored-by: Adam Turner <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Aug 10, 2024
pythonGH-122887)

In the documentation of `PosixPath` and `WindowsPath`, and their `Pure*`
equivalents, use example paths with multiple non-anchor parts.

(cherry picked from commit 363374c)

Co-authored-by: Barney Gale <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Aug 10, 2024
pythonGH-122887)

In the documentation of `PosixPath` and `WindowsPath`, and their `Pure*`
equivalents, use example paths with multiple non-anchor parts.

(cherry picked from commit 363374c)

Co-authored-by: Barney Gale <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
barneygale added a commit that referenced this issue Aug 10, 2024
…cs (GH-122887) (#122896)

GH-120794: Use example paths with multiple parts in pathlib docs (GH-122887)

In the documentation of `PosixPath` and `WindowsPath`, and their `Pure*`
equivalents, use example paths with multiple non-anchor parts.

(cherry picked from commit 363374c)

Co-authored-by: Barney Gale <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
barneygale added a commit that referenced this issue Aug 10, 2024
…cs (GH-122887) (#122895)

GH-120794: Use example paths with multiple parts in pathlib docs (GH-122887)

In the documentation of `PosixPath` and `WindowsPath`, and their `Pure*`
equivalents, use example paths with multiple non-anchor parts.

(cherry picked from commit 363374c)

Co-authored-by: Barney Gale <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
@barneygale
Copy link
Contributor

Sorted. Thanks again for reporting, @matkoniecz!

@matkoniecz
Copy link
Author

And thanks for processing suggestion! In many projects such issues are completely ignored, so it was kind of pleasant surprise to see this one actually implemented. It definitely makes me like Python even more.

blhsing pushed a commit to blhsing/cpython that referenced this issue Aug 22, 2024
python#122887)

In the documentation of `PosixPath` and `WindowsPath`, and their `Pure*`
equivalents, use example paths with multiple non-anchor parts.

Co-authored-by: Adam Turner <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir topic-pathlib
Projects
None yet
Development

No branches or pull requests

4 participants