semvec/pypi-packages huggingface dataset:
mathexpr 1.0.3
A library for parsing math strings
License: MIT

# MathExpr

MathExpr is a Python library for parsing and evaluating mathematical expressions.

## Table of Contents

* [Getting Started](#getting-started)
* [Features](#features)
* [Installation](#installation)
* [Usage](#usage)
* [Contributing](#contributing)
* [License](#license)

## Getting Started

To get started with this project, please follow these steps:

### Prerequisites

* Python 3.8+
* pip 20.0+

### Installation

To install the library, run the following command:
```bash
pip install mathexpr
```

## Features

MathExpr provides the following features:

* Parsing mathematical expressions
* Evaluating mathematical expressions
* Evaluating mathematical expressions with variables

## Usage

To use MathExpr, import the `MathParse` class and use the `parse` and `evaluate` methods.
Simple usage example:
```python
from mathexpr import MathExpr

math_string = "(2 + 3) * 4^3"
result = MathExpr.evaluate(math_string)
print(result)

>>> 320.0
```
Usage with variables:
```python
from mathexpr import MathExpr
math_string = "x + y"
result = MathExpr.evaluate(math_string, {"x": 2, "y": 3})
print(result)

>>> 5
```
Debug the AST:
```python
from mathexpr import MathExpr, print_ast

math_string = "(2 + 3) * 4^3"
ast = MathExpr.parse(math_string)
print_ast(ast)

>>> TokenType.MUL
>>> в”њв”Ђв”ЂTokenType.ADD
>>> в”‚  в”њв”Ђв”ЂNumNode(value=2.0)
>>> в”‚  в•°в”Ђв”ЂNumNode(value=3.0)
>>> в•°в”Ђв”ЂTokenType.POW
>>> в”‚  в”њв”Ђв”ЂNumNode(value=4.0)
>>> в”‚  в•°в”Ђв”ЂNumNode(value=3.0)
```

## Contributing

If you would like to contribute to this project, please fork the [repository](https://github.com/professionsalincpp/mathexpr) and create a pull request.

## License

This project is licensed under the MIT License - see the [LICENSE](https://github.com/professionsalincpp/mathexpr/blob/main/LICENSE) file for details.
rulea 1.1.2
Rule-based programmable language in Python
License: MIT
Requires Python: >=3.8

==============================
rulea - Syntax and Usage

Overview:

rulea is a rule-based language that clearly defines "who can do what."
With Python-like syntax, access or operation conditions are written in external .rulea files,
which can then be evaluated from within an application.

Basic Rule File Structure:

rule <rule_name>:  
    when: <condition_expression>  
    reason: "<reason if denied>"  
  
The when: section accepts both Python expressions and if statements.  
  
Multi-line conditions are supported.  
  
  
Examples:  
  
rule edit:  
    when: user == owner and status != "locked"  
    reason: "Only the owner can edit unlocked items"  
  
rule delete:  
    when:  
        if role == "admin":  
            True  
        elif user == owner:  
            status != "archived"  
        else:  
            False  
    reason: "Only admins or the owner (if not archived) can delete"  
  
Parameters are passed in externally as a context and are evaluated as variables.  
  
  
Using in Python:  
  
from rulea import RuleEngine  
  
engine = RuleEngine("access.rulea")  
ok, reason = engine.check("edit", {  
    "user": "alice",  
    "owner": "alice",  
    "status": "active"  
})  
  
if ok:  
    print("Allowed")  
else:  
    print("Denied:", reason)  
  
Using in CLI:  
  
rulea access.rulea edit \  
  --context '{"user": "alice", "owner": "bob", "status": "locked"}'  
  
Exit Codes:  
  
0 = Rule passed (allowed)  
  
1 = Rule failed (denied)  
  
  
Notes:  
  
when: supports expressions and if statements  
  
reason: is returned when the rule is denied  
  
Conditions are evaluated in a safe Python environment  
  
.rulea files must be saved in UTF-8 encoding