Skip to main content

dict-logic

Usage

Basic

from dictlogic import Logic

logic = Logic()
result = logic.run({
    'sequence': [
        {'print': 'hello world!'},
        {'set': ['a', 10]},
        {'print': ['the value of a is', {'get': 'a'}]},
        {'select': [
            {'>': [{'get': 'a'}, 5]},
            {'print': 'this expression will be evaluated'},
            {'print': 'this expression will be ignored'},
        ]},
        {'set': ['a', {'*': [{'get': 'a'}, 2]}]},
        {'get': 'a'},
    ],
})
assert(result == 20)

With given local variabls

from dictlogic import Logic

logic = Logic()
result = logic.run({
    'sequence': [
        {'print': ['the value of a is', {'get': 'a'}]},
        {'set': ['c', {'+': [{'get': 'a'}, {'get': 'b'}]}]},
        {'print': ['the value of c is', {'get': 'c'}]},
    ],
}, {
    'a': 5,
    'b': 3,
})

With custom functions

from dictlogic import Logic

logic = Logic()

@logic.add('sqrt')
def sqrt(x):
    return x() ** 0.5

@logic.add('mean')
def power(*args):
    args = [arg() for arg in args]
    return sum(args) / len(args)


logic.run({'print': {'sqrt': 2}})
logic.run({'print': {'mean': [1, 2, 3, 4, 5, 6, 7]}})

Metadata

Release files for dict-logic 1.0.2

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

Source distribution (sdist)

Source distribution for dict-logic 1.0.2
File Size Uploaded Provenance
dict-logic-1.0.2.tar.gz 3.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for dict-logic 1.0.2
File Interpreter ABI Platform
dict_logic-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 7.5 kB

Release files / dict-logic-1.0.2.tar.gz

Download URL dict-logic-1.0.2.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e70b064f6453725190a52d8b5758daf89f6ee566f5c0c565d6fe502c0b267dc5
BLAKE2b-256 checksum
How to use checksums
15b61844f4c32c1b9779145113957436142cb0b77c36f7863c61640b100a9689
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.0

Release files / dict_logic-1.0.2-py3-none-any.whl

Download URL dict_logic-1.0.2-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fc6ee021baa4d6f2a515986c0202e5dfd5466ab58936813226e86d477fb4fb0e
BLAKE2b-256 checksum
How to use checksums
d2fc852866021c3141571a2181195ea46e74d41a7a6145bf274c07057659e506
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.0

Security for dict-logic 1.0.2

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.

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files No provenance

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