Skip to main content

Implements callable using ctypes (useful on Python 3.0 and 3.1)

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

Python 3 initially removed the builtin function (but kept the internal C function), before adding it back in Python 3.2 because no alternative is truly equivalent in all cases.

This module provides a function named callable which is equivalent to the native callable, by directly accessing the underlying CPython API through the ctypes module.

This isn’t very useful by itself for most Python versions, but it is an essential building block for enabling code relying on callable to work on Python 3.0 and 3.1.

Versioning

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.

Installation

pip install ctypes-callable

Usage

The use-case for using this module is if:

  1. You are using an early CPython 3 release missing callable.

  2. You cannot upgrade to a newer CPython 3 for some reason.

  3. You want to use code which uses the callable builtin.

To do this, run this before any code that uses callable (for example, usercustomize or sitecustomize might be good places):

import ctypes_callable
import builtins
builtins.callable = ctypes_callable.callable

Portability

This module will fail on import on Jython, IronPython, PyPy, MicroPython, PyPy.js, Brython, Transcrypt, and probably any other implementation besides CPython, because it relies on accessing the Python C API through ctypes.

If you’re looking for something that’s basically this, but won’t break upon import on other Python implementations, you can use polyfill-callable.

Release files for ctypes-callable 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ctypes-callable 1.0.1
File Size Uploaded
ctypes-callable-1.0.1.tar.gz 3.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ctypes-callable 1.0.1
File Interpreter ABI Platform
ctypes_callable-1.0.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size:7.1 kB

Release files / ctypes-callable-1.0.1.tar.gz

Download URL ctypes-callable-1.0.1.tar.gz
Size 3.0 kB
Tags Source
SHA-256 checksum
How to use checksums
1b51117106f9a8ea1aa9cb5412b9b9b8dcad265df51a87d50793212d73ca4d38
BLAKE2b-256 checksum
How to use checksums
075f15503b579b8a37a39dca92610b124ec49e8fc14ffd66361a363eee19f57b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.3

Release files / ctypes_callable-1.0.1-py2.py3-none-any.whl

Download URL ctypes_callable-1.0.1-py2.py3-none-any.whl
Size 4.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
eb0f5b0a6dcecebc8f2270b3e91259eb98a34d248d0d1e6eb61289dc16eeca16
BLAKE2b-256 checksum
How to use checksums
6d2f68c949887c37fd935d8a28631cfd988d4af03b4b83890d7301d0438a401d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.3

Release history Release notifications | RSS feed

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page