Skip to main content

Modules providing forward compatibility across Python versions

Project description

https://img.shields.io/pypi/v/jaraco.compat.svg https://img.shields.io/pypi/pyversions/jaraco.compat.svg tests Ruff https://readthedocs.org/projects/jaracocompat/badge/?version=latest https://img.shields.io/badge/skeleton-2025-informational

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

♫ It’s going to be the future soon. It won’t always be this way, when the things that make me weak and strange get engineered away. ♫

Usage

Import functions from the appropriate compat.pyXX module in your python code. When a package is eventually ready to upgrade beyond pyXX, 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 compat.py25 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 py25 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.

Source Distribution

jaraco_compat-4.3.1.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

jaraco_compat-4.3.1-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file jaraco_compat-4.3.1.tar.gz.

File metadata

  • Download URL: jaraco_compat-4.3.1.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for jaraco_compat-4.3.1.tar.gz
Algorithm Hash digest
SHA256 8be915cbf8f696edf75377796e552e0c4e765226dde48ae15d9fb648161c39c8
MD5 a12b65bb8f3cc90ab5000c33ac1902e9
BLAKE2b-256 7f14a76986abe714b11445e48cf9872d98947d03dbe8806505358ecead1f6603

See more details on using hashes here.

File details

Details for the file jaraco_compat-4.3.1-py3-none-any.whl.

File metadata

  • Download URL: jaraco_compat-4.3.1-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for jaraco_compat-4.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 adfc0a0c6f3e047eb56bbfe0d66b30c7969227276309977284c540fbf35d7963
MD5 499e7b96584e48ce729ba07040bef653
BLAKE2b-256 d4438cbbfdb7cfdc2589254e2c37e5e9950a299e9337cd738a4d4526db1db542

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page