Skip to content

gh-130536: Improve os.path documentation #131872

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
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions Doc/library/os.path.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ the :mod:`glob` module.)
platforms, this is equivalent to calling the function :func:`normpath` as
follows: ``normpath(join(os.getcwd(), path))``.

.. seealso::
:func:`os.path.join` - for combining paths in an OS-independent way.

.. versionchanged:: 3.6
Accepts a :term:`path-like object`.

Expand Down Expand Up @@ -239,7 +242,10 @@ the :mod:`glob` module.)

.. function:: isabs(path)

Return ``True`` if *path* is an absolute pathname. On Unix, that means it
Return ``True`` if *path* is an absolute pathname.

.. seealso::
:func:`os.path.abspath` - for converting paths to absolute paths. On Unix, that means it
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a mess

Comment on lines +247 to +248
Copy link
Contributor

Choose a reason for hiding this comment

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

Usually these are put at the end of the note

begins with a slash, on Windows that it begins with two (back)slashes, or a
drive letter, colon, and (back)slash together.

Expand Down Expand Up @@ -352,7 +358,13 @@ the :mod:`glob` module.)

.. function:: join(path, *paths)

Join one or more path segments intelligently. The return value is the
Join one or more path segments intelligently.

Example::

>>> import os
>>> os.path.join("/home/foo", "/home/bar")
'/home/bar' The return value is the
concatenation of *path* and all members of *\*paths*, with exactly one
Comment on lines +367 to 368
Copy link
Contributor

Choose a reason for hiding this comment

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

Needs to be fixed

directory separator following each non-empty part, except the last. That is,
the result will only end in a separator if the last part is either empty or
Expand Down Expand Up @@ -488,7 +500,10 @@ the :mod:`glob` module.)
.. function:: split(path)

Split the pathname *path* into a pair, ``(head, tail)`` where *tail* is the
last pathname component and *head* is everything leading up to that. The
last pathname component and *head* is everything leading up to that.

.. seealso::
:func:`os.path.join` - for joining paths efficiently. The
*tail* part will never contain a slash; if *path* ends in a slash, *tail*
Comment on lines +506 to 507
Copy link
Contributor

Choose a reason for hiding this comment

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

Again a mess

will be empty. If there is no slash in *path*, *head* will be empty. If
*path* is empty, both *head* and *tail* are empty. Trailing slashes are
Expand Down
Loading