Implements ``callable`` using ctypes (useful on Python 3.0 and 3.1)
Project description
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:
You are using an early CPython 3 release missing callable.
You cannot upgrade to a newer CPython 3 for some reason.
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 the ``polyfill-callable` module <https://github.com/mentalisttraceur/python-polyfill-callable>`_ instead.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for ctypes-callable-1.0.0.post1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88c683d15c24c25842232452fb562587113ba18148983d9d3a02f6e9508404d6 |
|
MD5 | 02e2e58a3416ba8c4cf2ed2427334457 |
|
BLAKE2b-256 | b02a43732c3cdd670395b50bb82722e04b4c9233956055f0d8074984d0d87b70 |
Hashes for ctypes_callable-1.0.0.post1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99a69fab337d53747ede4e9b5648b281746caff8720dc804a2a3e204869e32d9 |
|
MD5 | 0f09870428a31a1a0edf60ffd6b35be4 |
|
BLAKE2b-256 | 06306abda69adfb2f64533a65a8d25560818223a56e630443be55c26cfc81c02 |