π 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
Or
pip install rs-calculator==0.2.0
π§ 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()
π‘οΈ 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
- GitHub: github.com/Rasa8877/rs-calculator
- PyPI: pypi.org/project/rs-calculator
- License: MIT
π 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)