About 80,700 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. python - Why is using 'eval' a bad practice? - Stack Overflow

    But they are rare. Using eval in your case is a bad practice for sure. I'm emphasizing on bad practice because eval and exec are frequently used in the wrong place. Replying to the …

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

    Nov 22, 2014 · 14 You can get to os using builtin functions: __import__('os'). For python 2.6+, the ast module may help; in particular ast.literal_eval, although it depends on exactly what you …

  4. python - Eval function with parameters - Stack Overflow

    Oct 10, 2016 · To call a function from a variable containing the name of the function, you can make use of the locals and globals function. Basically, you treat the output of locals() as a …

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

    173 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, …

  6. How can I assign the value of a variable using eval in python?

    Apr 8, 2011 · By the way, there are many ways to avoid using exec / eval if all you need is a dynamic name to assign, e.g. you could use a dictionary, the setattr function, or the locals() …

  7. Python3, best alternatives to eval()? (input as an expression)

    Feb 9, 2014 · I'm using Python 3. How can I input an expression without using eval (input ("Input: "))? I needed eval for an algebra calculator.

  8. 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 …

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

    Oct 12, 2018 · The short answer, or TL;DR Basically, eval is used to eval uate a single dynamically generated Python expression, and exec is used to exec ute dynamically …

  10. Python Programming: how to eval values from dictionary?

    Nov 11, 2015 · Python Programming: how to eval values from dictionary? Asked 9 years, 10 months ago Modified 9 years ago Viewed 21k times