Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:
Depending on your mental model of the language, this may not seem odd at all. >>> # We can set any key/value pair in any dictionary >>> d = {'x': 10, 'True': 20, 'for': 30} >>> # We can do regular string lookups at any time >>> d['x'] 10 >>> d['True'] 20 >>> d['for'] 30 >>> # globals() isn't special in this regard >>> globals().update(d) >>> globals()['x'] 10 >>> globals()['True'] 20 >>> globals()['for'] 30 >>> # Globals is special though in that it provides >>> # a fast way to do lookups for keys that are >>> # valid identifiers and are not keywords >>> x # Fast lookup equivalent to globals['x'] 10 >>> True # This is a keyword, so there is no lookup True >>> for # This is a keyword, so there is no lookup SyntaxError: invalid syntax At any rate, this isn't a bug. It is just the way the language works. Thank you for the report. ---------- nosy: +rhettinger resolution: -> not a bug stage: -> resolved status: open -> closed _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue37318> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com