Skip to main content

Modules providing forward compatibility across some Python 2.x versions

Project description

https://img.shields.io/pypi/v/jaraco.compat.svg https://img.shields.io/pypi/pyversions/jaraco.compat.svg https://img.shields.io/travis/jaraco/jaraco.compat/master.svg Code style: Black https://readthedocs.org/projects/jaracocompat/badge/?version=latest

Forward compatibility for Python packages, allowing future constructs to be borrowed before they’re available in the standard library.

This package is generally deprecated in favor of more surgical backports in separate packages.

Usage

Import functions from the appropriate pyXXcompat module in your python code. When you’re eventually ready to upgrade beyond pyXX, you can easily locate (with a grep) and replace those functions with the canonical implementations.

Example

Say you want a namedtuple (introduced in Python 2.6) in a project which supports Python 2.5 and greater:

from py25compat import namedtuple
MyTuple = namedtuple('MyTuple', 'a b c')
mt = MyTuple(1,2,3)

With jaraco.compat installed, this code will run on Python 2.5 and greater. When the project is ready to move to Python 2.6, one can easily grep for py25compat and make the necessary replacements with minimal impact on the code. In this case:

from collections import namedtuple
MyTuple = namedtuple('MyTuple', 'a b c')
mt = MyTuple(1,2,3)

Project details


Download files

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

Files for jaraco.compat, version 3.1
Filename, size File type Python version Upload date Hashes
Filename, size jaraco.compat-3.1-py2.py3-none-any.whl (7.3 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size jaraco.compat-3.1.tar.gz (12.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page