eval in Python works like in many functional programming languages. It evaluates the input string as if it were a Python expression. Python’s eval can only handle expressions, so is pretty limited.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| x = 1 | |
| y = eval( "x + 1" ) # 2 | |
| f = eval( "lambda x: x * x" ) | |
| g = f( 10 ) # 100 |
Tried with: Python 3.2