About 2,240,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

    Jul 6, 2009 · 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 …

  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 …

  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 …

  5. 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, …

  6. 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, …

  7. python - Dynamically evaluate an expression from a formula in …

    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 …

  8. python - Safe eval () by explitily whitelisting builtins and bailing on ...

    Jan 14, 2025 · I know it's inadvisable to use eval() on untrusted input, but I want to see where this sanitiser fails. It uses a whitelist to only allow harmless builtins, and it immediately bails if there …

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

    Mar 3, 2010 · 12 The reason eval and exec are so dangerous is that the default compile function will generate bytecode for any valid python expression, and the default eval or exec will …

  10. python - How to convert string representation of list to a list

    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 …