r/Python • • 22d ago

Showcase Showcase Thread

Post all of your code/projects/showcases/AI slop here.

Recycles once a month.

28 Upvotes

159 comments sorted by

View all comments

1

u/a8691 21d ago

GitHub: https://github.com/AndreiPuchko/q2eval

What My Project Does

I made a small Python library called q2eval.

It lets you evaluate expressions using variables stored in a dictionary. You can evaluate multiple expressions with the same dictionary or reuse one expression with different dictionaries.

It uses Python's eval() with a whitelist to restrict what expressions can access.

Target Audience

This is a small experimental project, not something I'd recommend for production use yet.

I'd especially like to hear from people interested in Python security. Can you find a way around the restrictions or access something that should be blocked?

Feel free to break it!

Comparison

I know there are other projects that provide safe expression evaluation, such as simpleeval. I made q2eval to solve a specific problem in my own project, and I'm interested in how this approach compares and what I might have missed.