Skip to main content

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)

Source distribution for chemformulapy 1.0.0
File Size Uploaded
chemformulapy-1.0.0.tar.gz 7.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for chemformulapy 1.0.0
File Interpreter ABI Platform
chemformulapy-1.0.0-py3-none-any.whl Python 3 none any Details

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

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page