Skip to main content

A backport of recent additions to the 'collections.abc' module.

Project description

Usage:

try:
    # ABCs live in "collections.abc" in Python >= 3.3
    from collections.abc import Coroutine, Generator
except ImportError:
    # fall back to import from "backports_abc"
    from backports_abc import Coroutine, Generator

You can also install the ABCs into the stdlib by calling the patch() function:

import backports_abc
backports_abc.patch()

try:
    # ABCs live in "collections.abc" in Python >= 3.3
    from collections.abc import Coroutine, Generator
except ImportError:
    # fall back to import from "collections" in Python <= 3.2
    from backports_abc import Coroutine, Generator

Currently, patch() provides the following names if missing:

  • collections.abc.Generator

  • collections.abc.Awaitable

  • collections.abc.Coroutine

  • inspect.isawaitable(obj)

All of them are also available directly from the backports_abc module namespace.

In Python 2.x and Python 3.2, it patches the collections module instead of the collections.abc module. Any names that are already available when importing this module will not be overwritten.

The names that were previously patched by patch() can be queried through the mapping in backports_abc.PATCHED.

Changelog

0.4 (2015-09-14)

  • direct wheel building support

  • make all names available at the module level instead of requiring patching

0.3 (2015-07-03)

  • removed patching of inspect.iscoroutine() as it is not ABC based

0.2 (2015-07-03)

  • require explicit backports_abc.patch() call to do the patching (avoids side-effects on import and allows future configuration)

  • provide access to patched names through global PATCHED dict

  • add ABC based implementations of inspect.iscoroutine() and inspect.isawaitable()

0.1 (2015-06-24)

  • initial public release

  • provided ABCs: Generator, Coroutine, Awaitable

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

backports_abc-0.4.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

backports_abc-0.4-py2.py3-none-any.whl (5.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file backports_abc-0.4.tar.gz.

File metadata

  • Download URL: backports_abc-0.4.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for backports_abc-0.4.tar.gz
Algorithm Hash digest
SHA256 8b3e4092ba3d541c7a2f9b7d0d9c0275b21c6a01c53a61c731eba6686939d0a5
MD5 0b65a216ce9dc9c1a7e20a729dd7c05b
BLAKE2b-256 f5d01d02695c0dd4f0cf01a35c03087c22338a4f72e24e2865791ebdb7a45eac

See more details on using hashes here.

File details

Details for the file backports_abc-0.4-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for backports_abc-0.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c64508e766dfe09a94a442c12b57c6e098a402921ecb340a4ec57c7e10fd464c
MD5 c36901a538881e8113dfd0feca2d83bc
BLAKE2b-256 f55e57e1afdc63d8c37496b2f6d9cb0ddfc4a3d55c949074debeab7594c19b54

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