Skip to main content

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:

  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.

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

ctypes-callable-1.0.1.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

ctypes_callable-1.0.1-py2.py3-none-any.whl (4.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file ctypes-callable-1.0.1.tar.gz.

File metadata

  • Download URL: ctypes-callable-1.0.1.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for ctypes-callable-1.0.1.tar.gz
Algorithm Hash digest
SHA256 1b51117106f9a8ea1aa9cb5412b9b9b8dcad265df51a87d50793212d73ca4d38
MD5 b52a987c230d9a61491c2b1cc5d64890
BLAKE2b-256 075f15503b579b8a37a39dca92610b124ec49e8fc14ffd66361a363eee19f57b

See more details on using hashes here.

File details

Details for the file ctypes_callable-1.0.1-py2.py3-none-any.whl.

File metadata

  • Download URL: ctypes_callable-1.0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using 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

File hashes

Hashes for ctypes_callable-1.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 eb0f5b0a6dcecebc8f2270b3e91259eb98a34d248d0d1e6eb61289dc16eeca16
MD5 d2bf8c35c1f61da8bc36cc28a2999931
BLAKE2b-256 6d2f68c949887c37fd935d8a28631cfd988d4af03b4b83890d7301d0438a401d

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