chemformulapy
A lightweight Python package for parsing, analyzing, and working with chemical formulas.
chemformulapy provides tools to:
- Parse chemical formulas into structured representations
- Compute molar masses
- Work with chemical elements and their properties
- Generate chemically intuitive formula orderings
🚀 Features
- 🧪 Parse formulas like
H2O,C6H12O6,KNO3,H2SO4 - ⚖️ Calculate molar masses using built-in element data
- 🔬 Access element properties (atomic number, molar mass, electronegativity)
- 📐 Chemically intuitive ordering of elements
- 🧩 Extensible design using enums and descriptors
📦 Installation
pip install chemformulapy
⚡ Quick Start
from chemformulapy import Element
oxygen = Element.O
print(oxygen.name)
print(oxygen.mass())
🧠 Use Cases
Molar Mass Calculation
from chemformulapy import parse_formula
formula = "H2O"
mass = parse_formula(formula).mass()
print(mass)
Chemical Formula Parsing
compound = parse_formula("C6H12O6")
print(compound.elements)
Element Property Analysis
from chemformulapy import Element
carbon = Element.C
print(carbon.value)
📥 Example Scripts
molar_mass_calculator.py
from chemformulapy import parse_formula
formula = input("Enter chemical formula: ")
compound = parse_formula(formula)
print(f"Molar mass of {formula}: {compound.mass()} g/mol")
element_lookup.py
from chemformulapy import Element
symbol = input("Enter element symbol: ")
element = Element[symbol]
print(f"Atomic number: {element.number}")
print(f"Molar mass: {element.mass}")
print(f"Electronegativity: {element.eneg}")
formula_parser_demo.py
from chemformulapy import parse_formula
formula = "H2SO4"
compound = parse_formula(formula)
print("Parsed formula:", compound.elements)
🧩 API Overview
Element Enum
Represents chemical elements with:
- Atomic number
- Molar mass
- Electronegativity
🛠️ Dependencies
- numpy
- pyparsing
🤝 Contributing
Contributions are welcome!
📄 License
MIT License
👤 Author
Evgenii Nekhoroshev, contact at evgnekhoroshev@gmail.com
Metadata
Release files for chemformulapy 1.0.0
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 |
|---|---|---|---|---|
| chemformulapy-1.0.0.tar.gz | 7.9 kB | Without provenance | Details for chemformulapy-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| chemformulapy-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for chemformulapy-1.0.0-py3-none-any.whl |
Total release size: 16.7 kB
Release files / chemformulapy-1.0.0.tar.gz
| Download URL | chemformulapy-1.0.0.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f45a4e16164dfb872512198ec8f9371ae803d501e662026ccb4349e4b972e3db
|
|
BLAKE2b-256 checksum How to use checksums |
6d5217697819eddb8e700d3fc95ea91ac2280f69fcec51765fdaee188734b624
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.2 CPython/3.11.7 Windows/10
|
Release files / chemformulapy-1.0.0-py3-none-any.whl
| Download URL | chemformulapy-1.0.0-py3-none-any.whl |
|---|---|
| Size | 8.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d088f8609e9bffde300b2831ff899ea455c22413c4ddb8ff60c4398917a8d14d
|
|
BLAKE2b-256 checksum How to use checksums |
d78a9c4fb9717fda0103f0dcf3a5556e57624fc011f8f680e365cacf408b88a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.2 CPython/3.11.7 Windows/10
|
Security for chemformulapy 1.0.0
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.