Python eval() Function

❮ Built-in Functions


Example

Evaluate the expression 'print(55)':

x = 'print(55)'
eval(x)
Try it Yourself »

Definition and Usage

The eval() function evaluates the specified expression, if the expression is a legal Python statement, it will be executed.


Syntax

eval(expression, globals, locals)

Parameter Values

Parameter Description
expression A String, that will be evaluated as Python code
globals Optional. A dictionary containing global parameters
locals Optional. A dictionary containing local parameters

❮ Built-in Functions

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.