semvec/pypi-packages huggingface dataset:
numexpr-preparser 1.0.0
Infix pre-parser/expression validator for numexpr
Requires Python: >=3.7


# Infix pre-parser for [numexpr](https://github.com/pydata/numexpr)

This is an infix parser for the basic syntax outlined in the `numexpr` user guide.
It may not correctly parse every supported numexpr expression, but it does offer strict parsing of a subset of numexpr syntax.

It is defined using the [pyparsing package](https://pypi.org/project/pyparsing/)

Not supported at this time/known issues
 * String constants are not yet supported, and will not be sucessfully parsed
 * the axis keyword in numexpr `sum` and `prod` will not be sucessfully parsed

It can be used as numexpr pre-parser/validator:

 * ensure string expressions are strictly infix expressions
 * get detailed error feedback for parsing errors via pyparsing
 * assert only function names that are supported in numexpr
 * assert identifiers are valid python identifiers
 * assert that only the numexpr unary and binary operators are used

constant values supported are:
 * floating point with scientific and complex notation
 * integers

Installation

```
pip install numexpr_preparser
```

Example usage:

Using as a pre-parser, to reject expressions that are not strictly infix
notation with the documented `numexpr` syntax

```python
import numexpr
from numexpr_preparser import parser as preparser

def numexpr_safe_evaluate(ex: str, *args, **kwargs):
    parse_success, results = preparser.get_parser().run_tests(
        ex, print_results=False
    )
    if not parse_success:
        raise ValueError(results[0][1])
    return numexpr.evaluate(ex, *args, **kwargs)
```
better-exception 0.0.1
BetterException is a Python library that enhances exception handling, including integration with GPT-3 for additional context.
Keywords: exception handling,GPT-3,Python library


# BetterException Documentation

The BetterException library provides an improved exception handling mechanism in Python. It allows you to enhance the output of exceptions, including sending them to GPT-3 for additional context.

## Installation

To install BetterException, use pip:

```bash
pip install better-exception
```


## Example

Here's an example of how to use BetterException:

```python
from better_exception import BetterException

BetterException()

x = "SADfsadf" + 5

# BetterException will enhance the exception output and will add COLORS!
# OUTPUT:
<module>, TypeError(Can only concatenate str (not "int") to str)
main, Line 82 -> m = "SADfsadf" + 5

```

## Class: BetterException

The BetterException class provides the following attributes and methods:

### Attributes

- `gpt_key` (str): Your GPT API key.
- `use_colors` (bool): Whether to use colors in the output.


## GPT3.5 Usage

Import the BetterException class and initialize it with your GPT API key.

```python
from better_exception import BetterException

# Initialize BetterException with your GPT API key
BetterException(gpt_key="YOUR_GPT_API_KEY")

result = 0/0

# OUTPUT:
<module>, ZeroDivisionError(Division by zero)
main, Line 80 -> result = 0/0

Waiting for GPT to respond...

The error "ZeroDivisionError" is raised when you try to divide a number by zero in Python. Division by zero is not defined in mathematics, hence this error is generated to indicate an invalid operation.
To fix this error, you need to make sure you do not divide a number by zero. If the denominator can potentially be zero in your code, you can add a check to handle this scenario using an if condition. For example:

try:
    result = 0/0
except ZeroDivisionError:
    print("Cannot divide by zero")

In this case, if the division operation encounters a ZeroDivisionError, it will be caught by the except block, which will then print the error message.

```