This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients ChrisRands, rhettinger
Date 2019-06-17.22:07:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1560809276.92.0.542204311391.issue37318@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2019-06-17 22:07:56rhettingersetrecipients: + rhettinger, ChrisRands
2019-06-17 22:07:56rhettingersetmessageid: <1560809276.92.0.542204311391.issue37318@roundup.psfhosted.org>
2019-06-17 22:07:56rhettingerlinkissue37318 messages
2019-06-17 22:07:56rhettingercreate