Name

eval

Synopsis

eval(expr,[globals[,locals]])

Returns the result of an expression. expr may be a code object ready for evaluation or a string. In the case of a string, eval gets a code object by calling compile( expr, 'string', 'eval'). eval evaluates the code object as an expression, using the globals and locals dictionaries as namespaces. When both arguments are missing, eval uses the current namespace. eval cannot execute statements; it can only evaluate expressions. For more information on eval, see Chapter 13.

Get Python in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.