8000 gh-87691: clarify use of anchor in pathlib docs by hauntsaninja · Pull Request #100782 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-87691: clarify use of anchor in pathlib docs #100782

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

Merged
merged 7 commits into from
Jan 6, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
use segment
  • Loading branch information
hauntsaninja committed Jan 6, 2023
commit 9be64100576f8dae7f674919c5445ddb6e23050f
28 changes: 14 additions & 14 deletions Doc/library/pathlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,24 +96,24 @@ Pure path objects provide path-handling operations which don't actually
access a filesystem. There are three ways to access these classes, which
we also call *flavours*:

.. class:: PurePath(*pathcomponents)
.. class:: PurePath(*pathsegments)

A generic class that represents the system's path flavour (instantiating
it creates either a :class:`PurePosixPath` or a :class:`PureWindowsPath`)::

>>> PurePath('setup.py') # Running on a Unix machine
PurePosixPath('setup.py')

Each element of *pathcomponents* can be either a string representing a
path component, an object implementing the :class:`os.PathLike` interface
Each element of *pathsegments* can be either a string representing a
path segment, an object implementing the :class:`os.PathLike` interface
which returns a string, or another path object::

>>> PurePath('foo', 'some/path', 'bar')
PurePosixPath('foo/some/path/bar')
>>> PurePath(Path('foo'), Path('bar'))
PurePosixPath('foo/bar')

When *pathcomponents* is empty, the current directory is assumed::
When *pathsegments* is empty, the current directory is assumed::

>>> PurePath()
PurePosixPath('.')
Expand Down Expand Up @@ -155,17 +155,17 @@ we also call *flavours*:
.. versionchanged:: 3.6
Added support for the :class:`os.PathLike` interface.

.. class:: PurePosixPath(*pathcomponents)
.. class:: PurePosixPath(*pathsegments)

A subclass of :class:`PurePath`, this path flavour represents non-Windows
filesystem paths::

>>> PurePosixPath('/etc')
PurePosixPath('/etc')

*pathcomponents* is specified similarly to :class:`PurePath`.
*pathsegments* is specified similarly to :class:`PurePath`.

.. class:: PureWindowsPath(*pathcomponents)
.. class:: PureWindowsPath(*pathsegments)

A subclass of :class:`PurePath`, this path flavour represents Windows
filesystem paths, including `UNC paths`_::
Expand All @@ -175,7 +175,7 @@ we also call *flavours*:
>>> PureWindowsPath('//server/share/file')
PureWindowsPath('//server/share/file')

*pathcomponents* is specified similarly to :class:`PurePath`.
*pathsegments* is specified similarly to :class:`PurePath`.

.. _unc paths: https://en.wikipedia.org/wiki/Path_(computing)#UNC

Expand Down Expand Up @@ -689,7 +689,7 @@ Concrete paths are subclasses of the pure path classes. In addition to
operations provided by the latter, they also provide methods to do system
calls on path objects. There are three ways to instantiate concrete paths:

.. class:: Path(*pathcomponents)
.. class:: Path(*pathsegments)

A subclass of :class:`PurePath`, this class represents concrete paths of
the system's path flavour (instantiating it creates either a
Expand All @@ -698,27 +698,27 @@ calls on path objects. There are three ways to instantiate concrete paths:
>>> Path('setup.py')
PosixPath('setup.py')

*pathcomponents* is specified similarly to :class:`PurePath`.
*pathsegments* is specified similarly to :class:`PurePath` 8542 .

.. class:: PosixPath(*pathcomponents)
.. class:: PosixPath(*pathsegments)

A subclass of :class:`Path` and :class:`PurePosixPath`, this class
represents concrete non-Windows filesystem paths::

>>> PosixPath('/etc')
PosixPath('/etc')

*pathcomponents* is specified similarly to :class:`PurePath`.
*pathsegments* is specified similarly to :class:`PurePath`.

.. class:: WindowsPath(*pathcomponents)
.. class:: WindowsPath(*pathsegments)

A subclass of :class:`Path` and :class:`PureWindowsPath`, this class
represents concrete Windows filesystem paths::

>>> WindowsPath('c:/Program Files/')
WindowsPath('c:/Program Files')

*pathcomponents* is specified similarly to :class:`PurePath`.
*pathsegments* is specified similarly to :class:`PurePath`.

You can only instantiate the class flavour that corresponds to your system
(allowing system calls on non-compatible path flavours could lead to
Expand Down
0