Skip to main content

Small Python library to check if a character is a punctuation character

Project description

ispunct

A small Python library for checking whether a character is a punctuation character.


Quick Start

from ispunct import ispunct

assert ispunct("?")
assert not ispunct("a")
assert ispunct("‽")

Using ispunct as a Library

This package is published on PyPI. You can install it with PIP:

$ pip add ispunct

Or, if using UV for dependency management:

$ uv add ispunct

History

The origin of this project comes from an equivalent function to Julia's ispunct, which is itself derived from the C implementation for obtaining a Unicode character's category code. This is a more complete solution than checking against string.punctuation or curses.ascii.ispunct. There is also a StackOverflow question for this functionality which I have answered.

Notes on Internal Functionality

This library also implements (and uses internally) bitwise functions to calculate the number of leading/trailing zeros/ones in the bitwise representation of a Python integer. We also compute a Python integer that has the same bitpattern as a given character (i.e., simulating Julia's bitcast). These are required in order to determine a character's category code.

Citation

If your research depends on ispunct, please consider giving us a formal citation: citation.bib.

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

ispunct-1.0.2.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ispunct-1.0.2-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file ispunct-1.0.2.tar.gz.

File metadata

  • Download URL: ispunct-1.0.2.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ispunct-1.0.2.tar.gz
Algorithm Hash digest
SHA256 41113dfb37edc82581c4b630fa8fc9d39e034e9ae6d16ec282a150e91beba04f
MD5 4aee52bd10502fd5699b42d11cd6a232
BLAKE2b-256 409fed8faed9f66b9a16d190944b40eff77456073099ce7f214db42d776f5976

See more details on using hashes here.

File details

Details for the file ispunct-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: ispunct-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ispunct-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 08d3008b2797ecf355ecea60c792233eb5c60cd3ad893e10860eddd73a00b16c
MD5 9618eb4ca1416267b263dfb070c09ecd
BLAKE2b-256 f6d3785fbb5b1cb90c82e1c1756c6e6f937d6bfcace3e9facd5a2154fcf4ff89

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page