Locals Vs Globals
-
when I run
def _fn(): localstate=0 if 'localstate' not in locals(): print('no local state') globalstate=0 if 'globalstate' not in globals(): print('no global state') _fn()
I get
>>> no local state >
Can anyone see why globals() works but locals() doesn't?
-
long sigh
-
@kjm locals() is not implemented properly in MicroPython. Calling it returns the same set as globals(). There was some discussion about it in the mothership https://forum.micropython.org or the issues sections of https://github.com/micropython/micropython