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.1.tar.gz (5.3 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.1-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ispunct-1.0.1.tar.gz
  • Upload date:
  • Size: 5.3 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.1.tar.gz
Algorithm Hash digest
SHA256 42753829e8e8b38bf02dddfb35948aa032dde6103dc2b921c1e9bf11c0f8b49b
MD5 b780238aab675a6181527aabeaf3624d
BLAKE2b-256 17efb0fe83dbdeafcc80bd1b22233929599d6067bdeda55f4ef4bfda12ea8070

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ispunct-1.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c6971ebd0202d73299550f2e4eafcdf39b1fb3f06c5a117425a14cd41935a2e0
MD5 815e708499d6eb5d9c3b0637049a8f1a
BLAKE2b-256 3935a79c3c1438f58aa47ea544f41320cec6bd9a299fbfa0caf1e1f6ee71f591

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