Message345927
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. |
|
Date |
User |
Action |
Args |
2019-06-17 22:07:56 | rhettinger | set | recipients:
+ rhettinger, ChrisRands |
2019-06-17 22:07:56 | rhettinger | set | messageid: <1560809276.92.0.542204311391.issue37318@roundup.psfhosted.org> |
2019-06-17 22:07:56 | rhettinger | link | issue37318 messages |
2019-06-17 22:07:56 | rhettinger | create | |
|