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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42753829e8e8b38bf02dddfb35948aa032dde6103dc2b921c1e9bf11c0f8b49b
|
|
| MD5 |
b780238aab675a6181527aabeaf3624d
|
|
| BLAKE2b-256 |
17efb0fe83dbdeafcc80bd1b22233929599d6067bdeda55f4ef4bfda12ea8070
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6971ebd0202d73299550f2e4eafcdf39b1fb3f06c5a117425a14cd41935a2e0
|
|
| MD5 |
815e708499d6eb5d9c3b0637049a8f1a
|
|
| BLAKE2b-256 |
3935a79c3c1438f58aa47ea544f41320cec6bd9a299fbfa0caf1e1f6ee71f591
|