Skip to main content

This package monkey-patches some useful extensions on to pathlib from the Python standard library. These extensions are only supported on Posix systems.

Once installed, you can simply import Path from extended_pathlib just as you would from pathlib, and use the new functionality:

>>> from extended_pathlib import Path

>>> tmp = Path('/tmp')
>>> tmp.is_readable()
True

Installation

Use ‘pip3 install extended_pathlib’ to install. Requires Python2.7 or Python3.4 or better.

https://travis-ci.org/KenKundert/extended_pathlib.svg?branch=master

File Types

is_readable

Returns True if the given path points to an existing file or directory that is readable.

>>> Path('/usr/bin/python').is_readable()
True

is_writable

Returns True if the given path points to an existing file or directory that is writable.

>>> Path('/usr/bin/python').is_writable()
False

is_executable

Returns True if the given path points to an existing file or directory that is executable.

>>> Path('/usr/bin/python').is_executable()
True

is_hidden

Returns True if the given path points to an existing file or directory that is hidden (starts with ‘.’).

>>> Path('/usr/bin/python').is_hidden()
False

is_newer

Returns True if the given path is newer than the reference. The reference may be a timestamp, a datetime object, or another path.

>>> Path('/usr/bin/python').is_newer(0)
True

path_from

Returns relative path from start as a path object. This differs from Path.relative_to() in that relative_to() will not return a path that starts with ‘..’.

>>> cwd = Path('.')
>>> cwd.path_from('..')
PosixPath('tests')

sans_ext

Removes the file extension. This differs from Path.stem, which returns the final path component stripped of its extension. This returns the full path stripped of its extension.

>>> Path('a/b.c').sans_ext()
PosixPath('a/b')

write_bytes

Writes a binary file. This is the standard pathlib write_bytes() that was introduced in Python3.5, but back-ported to earlier versions.

write_text

Reads a binary file. This is the standard pathlib write_text() that was introduced in Python3.5, but back-ported to earlier versions.

read_bytes

Reads a binary file. This is the standard pathlib read_bytes() that was introduced in Python3.5, but back-ported to earlier versions.

read_text

Reads a text file. This is the standard pathlib read_text() that was introduced in Python3.5, but back-ported to earlier versions.

expanduser

Expand leading tilde (~) in paths.

Metadata

Release files for extended-pathlib 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for extended-pathlib 0.5.0
File Size Uploaded
extended_pathlib-0.5.0.tar.gz 4.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for extended-pathlib 0.5.0
File Interpreter ABI Platform
extended_pathlib-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.6 kB

Release files / extended_pathlib-0.5.0.tar.gz

Download URL extended_pathlib-0.5.0.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
49861e6f7de90a5643d415ffe72ccac1c40207fba40cafa98f2761ea37dda97f
BLAKE2b-256 checksum
How to use checksums
c511b4721078ca7785ed97b6f35de9597bf10db8aa27f5f87158b058feabf474
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/0.0.0 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.2

Release files / extended_pathlib-0.5.0-py3-none-any.whl

Download URL extended_pathlib-0.5.0-py3-none-any.whl
Size 16.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
87a6b5a171485c8e83ebedbebc7be30ff0ffce2ebfe29a1dab39a98436259a3e
BLAKE2b-256 checksum
How to use checksums
8480d6566994df813e29379212bb8da2d43e4a5c0bb2e587d1787fa613c2a613
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/0.0.0 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.2

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files

0.4.0

1 release file

0.3.0

1 release file

0.2.0

1 release file

0.1.0

1 release file

0.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page