I'm using Python 3.
I suppose the best way to ask this is how can I input an expression without using eval(input("Input: "))?
I'm a simple user right now, so what I needed eval for was an algebra calculator.
I'm using Python 3.
I suppose the best way to ask this is how can I input an expression without using eval(input("Input: "))?
I'm a simple user right now, so what I needed eval for was an algebra calculator.
Depending on how complicated your expressions are, ast.literal_eval may be a safer alternative.
If you're the only person using that app and thus don't need to be worried about security issues, just keep using eval() or exec().
Otherwise, just use a safe library for the specific task you need. E.g. numexpr I guess for a calculator.
how can I input an expression without using eval(input("Input: "))
simply don;t use eval. In Python 3.x, input is the replacement for raw_input so, you don't need eval. You can simply write your statement as input("Input: ")
Moreover, in Python 2.X, you should have used raw_input("Input: ") instead of eval(input("Input: "))