Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Attention: this backport module isn't maintained anymore. If you want to report issues or contribute patches, please consider the pathlib2 <https://pypi.python.org/pypi/pathlib2/>
_ project instead.
pathlib offers a set of classes to handle filesystem paths. It offers the following advantages over using string objects:
No more cumbersome use of os and os.path functions. Everything can be done easily through operators, attribute accesses, and method calls.
Embodies the semantics of different path types. For example, comparing Windows paths ignores casing.
Well-defined semantics, eliminating any warts or ambiguities (forward vs. backward slashes, etc.).
Python 3.2 or later is recommended, but pathlib is also usable with Python 2.7 and 2.6.
In Python 3.4, pathlib is now part of the standard library. For Python 3.3
and earlier, easy_install pathlib
or pip install pathlib
should do
the trick.
Importing the module classes::
from pathlib import *
Listing Python source files in a directory::
list(p.glob('*.py')) [PosixPath('test_pathlib.py'), PosixPath('setup.py'), PosixPath('pathlib.py')]
Navigating inside a directory tree::
p = Path('/etc') q = p / 'init.d' / 'reboot' q PosixPath('/etc/init.d/reboot') q.resolve() PosixPath('/etc/rc.d/init.d/halt')
Querying path properties::
q.exists() True q.is_dir() False
Opening a file::
with q.open() as f: f.readline() ... '#!/bin/bash\n'
The full documentation can be read at Read the Docs <https://pathlib.readthedocs.org/>
_.
Main development now takes place in the Python standard library: see
the Python developer's guide <http://docs.python.org/devguide/>
, and
report issues on the Python bug tracker <http://bugs.python.org/>
.
However, if you find an issue specific to prior versions of Python
(such as 2.7 or 3.2), you can post an issue on the
BitBucket project page <https://bitbucket.org/pitrou/pathlib/>
_.
Version 1.0.1 ^^^^^^^^^^^^^
Version 1.0 ^^^^^^^^^^^
This version brings pathlib
up to date with the official Python 3.4
release, and also fixes a couple of 2.7-specific issues.
Version 0.97 ^^^^^^^^^^^^
This version brings pathlib
up to date with the final API specified
in :pep:428
. The changes are too long to list here, it is recommended
to read the documentation <https://pathlib.readthedocs.org/>
_.
.. warning:: The API in this version is partially incompatible with pathlib 0.8 and earlier. Be sure to check your code for possible breakage!
Version 0.8 ^^^^^^^^^^^
Version 0.7 ^^^^^^^^^^^
Version 0.6 ^^^^^^^^^^^
Version 0.5 ^^^^^^^^^^^
FAQs
Object-oriented filesystem paths
We found that pathlib demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.