1""" 2categories: Core,Runtime 3description: Code running in eval() function doesn't have access to local variables 4cause: MicroPython doesn't maintain symbolic local environment, it is optimized to an array of slots. Thus, local variables can't be accessed by a name. Effectively, ``eval(expr)`` in MicroPython is equivalent to ``eval(expr, globals(), globals())``. 5workaround: Unknown 6""" 7val = 1 8 9 10def test(): 11 val = 2 12 print(val) 13 eval("print(val)") 14 15 16test() 17