DEV Community

Rasa Dariush
Rasa Dariush

Posted on

πŸš€ RS Calculator v0.2.0: Safer, Smarter, and Now Supports Full Math Expressions!

πŸš€ RS Calculator v0.2.0: Now Handles Full Expressions with Infinite Numbers, Operators, and Safety πŸ’₯

Hey Pythonistas! πŸ‘‹

I’m thrilled to announce a huge upgrade to my beginner-friendly calculator library: RS Calculator v0.2.0 πŸŽ‰

This version brings smarter math, safer evaluation, and a cleaner package design β€” all in one release!


✨ What’s New in v0.2.0?

βœ… Infinite numbers and operators β€” write full expressions like "2 + 3 * 4 - 1 / 5 + (6 ** 2)"

βœ… Parentheses and operator precedence now work correctly

βœ… Secure evaluation using asteval instead of risky eval()

βœ… Input validation: only math-safe characters allowed

βœ… Modern packaging with pyproject.toml

βœ… Clear error messages for division by zero and invalid input


πŸ“¦ Installation

Install via pip:

pip install rs-calculator 
Enter fullscreen mode Exit fullscreen mode

Or

pip install rs-calculator==0.2.0 
Enter fullscreen mode Exit fullscreen mode

🧠 How to Use

from rs_calculator import calculate, show_help # Infinite numbers and multiple operators print(calculate("2 + 3 * 4 - 1 / 5 + (6 ^ 2)")) # 40.8 print(calculate("10 + 5 * 2 - 3 // 2 + (8 % 3)")) # 20.5 print(calculate("5 ^ 2 + 10")) # 35  # Division by zero print(calculate("10 / 0")) # Error: Division by zero  # Help message show_help() 
Enter fullscreen mode Exit fullscreen mode

πŸ›‘οΈ Safe Expression Evaluation

No risky eval() calls!
RS Calculator now uses asteval, a safe math-only interpreter that:

  • Only evaluates valid math expressions
  • Rejects anything with unsafe characters or code
  • Supports only: 0-9, +, -, *, x, /, //, %, **, ^, (), and whitespace

🧱 Built for Beginners

I created rs_calculator to give new Python learners a clean, fun way to explore:

  • Packaging a Python module
  • Using safe expression evaluation
  • Understanding how a calculator works under the hood

πŸ“š Project Info


πŸ’Œ Let’s Connect

Have suggestions? Want to collaborate? Feel free to:

πŸ“¬ Email: letperhut@gmail.com
🌐 GitHub: @Rasa8877


If this helped you, please ⭐ the repo, share it with a fellow learner, or give me a shout!
Thanks for reading, and happy coding! πŸ™Œ

#python #pypi #opensource #beginners #devtools

Top comments (0)