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?
-
@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
-
long sigh
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login