About 3,870,000 results
Open links in new tab
  1. What does Python's eval() do? - Stack Overflow

    Eval function try to execute and interpret the string (argument) passed to it as python code. x=1 print (eval ('x+1')) Output of the above code will be 2.

  2. dynamic - Use of eval in Python - Stack Overflow

    Oct 30, 2015 · There is an eval() function in Python I stumbled upon while playing around. I cannot think of a case when this function is needed, except maybe as syntactic sugar. What could an example be?

  3. What's the difference between eval, exec, and compile?

    Oct 12, 2018 · I've been looking at dynamic evaluation of Python code, and come across the eval() and compile() functions, and the exec statement. Can someone please explain the difference between …

  4. Security of Python's eval() on untrusted strings? - Stack Overflow

    Nov 22, 2014 · eval() will allow malicious data to compromise your entire system, kill your cat, eat your dog and make love to your wife. There was recently a thread about how to do this kind of thing safely …

  5. Using python's eval () vs. ast.literal_eval () - Stack Overflow

    174 ast.literal_eval() only considers a small subset of Python's syntax to be valid: The string or node provided may only consist of the following Python literal structures: strings, bytes, numbers, tuples, …

  6. Python: make eval safe - Stack Overflow

    Aug 18, 2010 · If you're satisfied with plain expressions using elementary-type literals only, use ast.literal_eval -- that's what it's for! For anything fancier, I recommend a parsing package, such as …

  7. Dynamically evaluate an expression from a formula in Pandas

    With Python backend, your expression is evaluated similar to just passing the expression to Python's eval function. You have the flexibility of doing more inside expressions, such as string operations, for …

  8. python - Evaluating a mathematical expression in a string - Stack …

    Mar 3, 2010 · Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: invalid literal for int() with base 10: '2^4' I know that eval can work around this, but isn't there a better and - …

  9. python - How to convert string representation of list to a list - Stack ...

    ast.literal_eval is safer than eval, but it's not actually safe. As recent versions of the docs explain: "Warning It is possible to crash the Python interpreter with a sufficiently large/complex string due to …

  10. Python 3 - exec() Vs eval() - Expression evaluation - Stack Overflow

    Jun 22, 2017 · How eval () works different from exec () ? In your two cases, both eval() and exec() do, do the same things. They print the result of the expression. However, they are still both different. The …