Skip to main content

Standard atomic weights of the elements

Project description

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

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

atomic_weights-2023.0.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.0.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: atomic_weights-2023.0.0.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","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.0.0.tar.gz
Algorithm Hash digest
SHA256 06a534473a903511c68c16a3a881407fbcf87a6683425ee08a06c71341c3ff65
MD5 d6e2af82f789082b516eea86a88f8ec8
BLAKE2b-256 53414e99ccc096cffce33188ff0eb51b7b88007972b6a5b745fd1407a71a761e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: atomic_weights-2023.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","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.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7696cd3402028d143cba8db515fc0d5378fb6effc2325ce42dbe2a99cde16268
MD5 b52b3492f068d242f41cb6510b024f98
BLAKE2b-256 e9e243d83fe775559aa06ef683dffa9d0692cf421324816f7dea71198f82ddbe

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