Skip to main content

myaml

workflow License pypi

M(ath)YAML: evaluate math expressions in YAML files.

Install

pip install myaml

Usage

myaml allows you to define math expressions in YAML files:

# test.yaml
---
- x1:
    x: !eval 2**(3 - 1)
    y: !eval (12 % 9) - sqrt(9)
- x2:
    x: !eval (2**3) - 1.0
    y: !eval -0.75 ** (9 - cos(3.1415) * log(2.718))
- x3:
    x: hello world
    y: /this/is/a/path

Expressions annotated with !eval tag will be evaluated at load-time. Any other strings will be left intact:

>>> import myaml
>>> xs = myaml.safe_load('test.yaml')
>>> xs
[
    {'x1': {'x': 4, 'y': 0}},
    {'x2': {'x': 7, 'y': -0.056315}},
    {'x3': {
        'x': 'hello world',
        'y': '/this/is/a/path'
    }}
]

Notes

Metadata

Release files for myaml 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for myaml 1.0.1
File Size Uploaded
myaml-1.0.1.tar.gz 2.5 kB Details

Built distribution (wheel)

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

Total release size: 9.3 kB

Release files / myaml-1.0.1.tar.gz

Download URL myaml-1.0.1.tar.gz
Size 2.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6761ea4e271b2808cb1c91cb8abcfbde073d0b54649da37a67e5094b22e672b9
BLAKE2b-256 checksum
How to use checksums
cb3642e65be64c0a243064b44e29969b6f2d3d598933b8abad6dbdbe3f3550c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.7.0 requests/2.25.1 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

Release files / myaml-1.0.1-py3-none-any.whl

Download URL myaml-1.0.1-py3-none-any.whl
Size 6.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6dc04e22a7418b04bfb9747d847081add0896dad5b02388a6dc20b6d3d9d434b
BLAKE2b-256 checksum
How to use checksums
15969b6dbc05a680b9a6bd84e88298e6ede5d9b00f7a4e0481fac725b0aab63a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.7.0 requests/2.25.1 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.2

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