casregnum
Python class to manage, check and sort CAS Registry Numbers® (CAS RN®).
Table of Contents
Description
casregnum is a Python class to manage, check, and sort CAS Registry Numbers® (CAS RN®) by the Chemical Abstracts Service. Check their official FAQ website for more information on CAS numbers.
How to install and uninstall
casregnum can be installed from the Python Package Index (PyPI) repository by calling
pip install casregnum
or
uv add casregnum
In order to uninstall casregnum from your local environment use
pip uninstall casregnum
or
uv remove casregnum
How to use
casregnum provides the CAS class for creating a CAS Registry Number® instance:
from casregnum import CAS
substance = CAS(cas_rn)
Note that cas_rn can either be an integer or a string. If you provide an integer, the CAS class will take care of formatting the CAS RN® for you. If you provide a string, it needs to comply with the CAS number formatting rules, i. e. 2-7 digits dash two digits dash single check digit (_____00-00-0).
The CAS class offers the following three properties:
.cas_string # CAS number formatted as a string
.cas_integer # CAS number as an integer
.check_digit # check digit of the CAS number
Examples:
from casregnum import CAS
caffeine = CAS(58_08_2)
theine = CAS("58-08-2")
l_lacticacid = CAS(79_33_4)
d_lacticacid = CAS(10326_41_7)
octanes = [
CAS(111_65_9), CAS(592_27_8), CAS(589_81_1), CAS(589_53_7), CAS( 590_73_8), CAS(584_94_1),
CAS(589_43_5), CAS(592_13_2), CAS(563_16_6), CAS(583_48_2), CAS( 619_99_8), CAS(564_02_3),
CAS(540_84_1), CAS(560_21_4), CAS(565_75_3), CAS(609_26_7), CAS(1067_08_9), CAS(594_82_1),
]
print(f"str: {caffeine}")
print(f"int: {theine.cas_integer}")
print(f"check digit: {caffeine.check_digit}")
print(f"{caffeine} == {theine}: {caffeine == theine}")
print(f"{caffeine} > {theine}: {caffeine > theine}")
print(f"{l_lacticacid} > {d_lacticacid}: {l_lacticacid > d_lacticacid}")
print(f"{l_lacticacid} < {d_lacticacid}: {l_lacticacid < d_lacticacid}")
for i, isomer in enumerate(sorted(octanes), start=1):
print(f"{isomer:>9}", end=", ")
if i % 6 == 0:
print()
This will generate the following output:
str: 58-08-2
int: 58082
check digit: 2
58-08-2 == 58-08-2: True
58-08-2 > 58-08-2: False
79-33-4 > 10326-41-7: False
79-33-4 < 10326-41-7: True
111-65-9, 540-84-1, 560-21-4, 563-16-6, 564-02-3, 565-75-3,
583-48-2, 584-94-1, 589-43-5, 589-53-7, 589-81-1, 590-73-8,
592-13-2, 592-27-8, 594-82-1, 609-26-7, 619-99-8, 1067-08-9,
Metadata
Release files for casregnum 1.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| casregnum-1.1.2.tar.gz | 48.6 kB | Without provenance | Details for casregnum-1.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| casregnum-1.1.2-py3-none-any.whl | Python 3 | none | any | Details for casregnum-1.1.2-py3-none-any.whl |
Total release size: 54.6 kB
Release files / casregnum-1.1.2.tar.gz
| Download URL | casregnum-1.1.2.tar.gz |
|---|---|
| Size | 48.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7894a05a32560375f712538e9a2fa0841c7667e417dc54cdea8989ca913e70c2
|
|
BLAKE2b-256 checksum How to use checksums |
fb297b114e5addc4d142b3c17f0ea4612f41a7c6c5405e588c3216aa51113379
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.8.17
|
Release files / casregnum-1.1.2-py3-none-any.whl
| Download URL | casregnum-1.1.2-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
85f057cb1a7eb4b7480d8caa0e9d96d9f09c14665edc0b5515506ddda5467fe2
|
|
BLAKE2b-256 checksum How to use checksums |
9103284aee123075d95d949c01c28c4df0b904aa0bf662f01efc054022a6d4fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.8.17
|
Security for casregnum 1.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.