callable
polyfill
Python Attempts to ensure the callable
builtin is available.
- On versions of Python where
callable
is already available, importing this doesn't break anything and leavescallable
alone. - On versions without a
callable
builtin, on import this will attempt to inject an equivalent implementation, so that code invokingcallable
continues to work. - If your Python runtime has no
callable
builtin and this module is unable to polyfill it, it will raise aNotImplementedError
.
Versioning
This library's version numbers follow the SemVer 2.0.0 specification.
Installation
pip install polyfill-callable
Usage
Just make sure you run this before you run any other code that uses
callable
:
import polyfill_callable
You can also catch NotImplementedError
if you'd like to
gracefully handle the lack of callable
:
try:
import polyfill_callable
except NotImplementedError as error:
# .. do something ..
Limitations
Currently, this module only has a callable
polyfill for:
- The early CPython 3 versions that shipped without
callable
before it was added back in in CPython 3.2. There we can reimplement it usingctypes
, and polyfill it into the global namespace by usingbuiltins
.
If there are other Python implementation versions where it would be possible to support a polyfill, they might eventually be added here.