Skip to main content
Join the official Python Developers Survey 2018 and win valuable prizes: Start the survey!

Attempts to ensure the ``callable`` builtin is available.

Project description

Attempts to ensure the callable builtin is available.

Most Python versions have a native builtin function called callable which checks if the argument is a callable object.

This applies to all modern supported versions of CPython (including stackless), PyPy, Jython, IronPython, MicroPython, PyPy.js, Brython, and probably others, but there is a small handful of Python versions where callable isn’t implemented.

The concept behind this module is that it attempts to ensure that the callable builtin is available:

  • On versions of Python where callable is already available, importing this doesn’t break anything and leaves callable alone.
  • On versions without a callable builtin, on import this will attempt to inject an equivalent implementation, so that code invoking callable continues to work.
  • If your Python runtime has no callable builtin and this code is unable to polyfill it, it will raise a NotImplementedError.


This library’s version numbers follow the SemVer 2.0.0 specification.

The current version number is available in the variable __version__ as is normal for Python modules.


pip install polyfill-callable


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.

    import polyfill_callable
except NotImplementedError as error:
    # .. do something ..


As of this writing on 2018-02-17, 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 using ctypes, and polyfill it into the global namespace by using builtins.

If there are other Python implementation versions where it would be possible to support a polyfill, they might eventually be added here.

Release history Release notifications

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
polyfill_callable-1.0.0-py2.py3-none-any.whl (6.0 kB) Copy SHA256 hash SHA256 Wheel py2.py3 Feb 17, 2018
polyfill-callable-1.0.0.tar.gz (4.0 kB) Copy SHA256 hash SHA256 Source None Feb 17, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page