Logics is a user-friendly formula language with a subset of Python's expression syntax
Project description
About
Logics is a simple expression language with the goal to provide equal syntax and semantics for different runtime contexts and host languages.
- logics-js is a pure JavaScript implementation of Logics provided as npm-package.
- logics-py is a pure Python implementation of Logics provided as PyPI-package.
Both packages are under recent development and not stable right now. They are maintained in separate version numbers.
Features
- Secure, native, running in a sandboxed environment apart from the host language
- Disallows variable assignment, except in comprehensions
- logics-js: Implementation in JavaScript
- logics-py: Implementation in Python
- Python-inspired syntax and semantics
- Make use of all standard operators
- Unary
+
,-
,~
,not
- Binary
+
,*
,-
,/
,//
,**
- Comparison
==
,!=
,<>
,<
,<=
,>
,>=
,in
,not in
- Logical
and
,or
- Conditions
y if x else z
- Comprehensions
[x for x in y if z]
- Unary
- Slices
x[:]
- Attribute access
x[y]
# comments
in separate lines- Dedicated Value object abstraction of native types for
True
,False
,None
int
,float
,str
list
for arraysdict
for structured objects
- Make use of all standard operators
- Provides a set of functions that can be used in expressions
- Extendable to custom functions
Logics
vs. Python
Logics does look like Python, but it isn't Python!
- Expressions can be used with arbitrary whitespace and line-breaks
- There are no methods on objects, but functions that work on objects
- e.g.
dict.keys()
becomeskeys(dict)
";".join(["a", "b", "c"])
becomesjoin(["a", "b", "c"], ";")
- e.g.
- No exceptions, access to e.g. invalid index or key just returns
None
- Dynamic and automatic value conversion
- e.g. the content of strings is automatically converted when used in calculations,
so
"42" ** 3
produces 74088, and not a TypeError.
- e.g. the content of strings is automatically converted when used in calculations,
so
License
Copyright © 2023 by Mausbrand Informationssysteme GmbH.
Mausbrand and ViUR are registered trademarks of Mausbrand Informationssysteme GmbH.
Logics is free software under the MIT license.
Please see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
logics_py-0.0.4-py3-none-any.whl
(13.8 kB
view hashes)
Close
Hashes for logics_py-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7e5878541645ad681250b655a20daa03839ea11225ec4cd9d93b2d8d61b4dd3 |
|
MD5 | 3451b8096c3cbf8b98b461aa28eb5cd8 |
|
BLAKE2b-256 | 4117a9ca1f99e4ded2229af39abae7a31673d06dea6bb446b72b70fbd65bb477 |