Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Path manipulation library

Project Description

betterpath, or “bp”, is an adaptation of the classic Twisted FilePath type and interface. bp provides a simple, robust, well-tested object abstraction over file paths, generalizing the concept of file paths beyond filesystems.

File Paths

bp exposes an interface, bp.abstract.IFilePath, for file paths, and provides the following concrete implementations:

  • bp.filepath.FilePath, for the root filesystem
  • bp.zippath.ZipPath, for ZIP archives
  • bp.memory.MemoryPath, for in-memory temporary filesystems

In addition, there are combining abstract file paths which can be wrapped around other file paths:

  • bp.readonly.ReadOnlyPath, for read-only filesystems

API documentation is available at

Vs. the Competition


The venerable champ, os.path has been the cause of (and solution to) most of Python’s path problems over the years.


  • In the standard library


  • Unsafe
  • Verbose
  • Operates on strs
  • No interfaces or ABCs for functionality
  • Only covers the root filesystem


pathlib hopes to carve a path towards greatness through PEP 428.


  • Convenient __div__() overloading


  • No interfaces or ABCs for functionality
  • Only covers the root filesystem


Saving Data to Disk

The Old Way

def save(base, fragments, data):
    # `fragments` could contain unsafe paths!
    if ".." in fragments or "." in fragments:
        raise ValueError("Unsafe paths!")
    path = os.path.join(os.path.abspath(base), os.sep.join(fragments))
    # Alternatively: path = os.path.join(os.path.abspath(base), *fragments)
    # I hope that this doesn't fail mid-write! Also, did the directories
    # exist? I think so, yes.
    with open(path, "wb") as handle:

The New Way

def save(base, fragments, data):
    path = base.descendant(fragments)



  • Initial release

Release History

This version
History Node


History Node


History Node


History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(38.1 kB) Copy SHA256 Hash SHA256
Source None Feb 10, 2015

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers