Skip to main content

py-atomic-weights: Python Module for Standard atomic weights of the elements

Features

Usage

pip install atomic-weights
>>> import atomic_weights as atw
>>> print(atw.Fe)
55.845
>>> print(atw.decimal.Fe)
55.845
>>> type(atw.Fe)
<class 'float'>
>>> type(atw.decimal.Fe)
<class 'decimal.Decimal'>
import re
import unicodedata

import atomic_weights as atw


def molecular_mass(x: str) -> float:
    """formula -> g/mol"""

    x = unicodedata.normalize("NFKC", x)
    y = 0
    for elem, num in re.findall(r"(?:([A-Z][a-z]*)(\d+)?)", x):
        num = int(num) if num else 1
        y += num * getattr(atw, elem)
    return y

molecular_mass("Al2O3")
# 101.9600768
molecular_mass("Al₂O₃")
# 101.9600768

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

atomic_weights-2023.1.0.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

atomic_weights-2023.1.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file atomic_weights-2023.1.0.tar.gz.

File metadata

  • Download URL: atomic_weights-2023.1.0.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for atomic_weights-2023.1.0.tar.gz
Algorithm Hash digest
SHA256 2174b0f046d74158aa5b518e3c8c68c4828ad47c8937ec3bca08a34ebb40f232
MD5 8ce82bb179bea2e8fe2af33728a47e8c
BLAKE2b-256 7daa5239be87c6d8aed95869ed6ebb18f5d7052aecf3b8daf0cac6d86bbf74d6

See more details on using hashes here.

File details

Details for the file atomic_weights-2023.1.0-py3-none-any.whl.

File metadata

  • Download URL: atomic_weights-2023.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for atomic_weights-2023.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 03183f40d4cb68675bf942c0d72c46c312e0b3dc373d9041b66e18a7c7853019
MD5 182e314514e8323450c4667a33412475
BLAKE2b-256 3bf17c0f0d922e469f240815e741d5fb0ec9b3caf6e3c10309189c86da50350b

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 Sentry Error logging StatusPage Status page