Message414040
CPython, at least, allows users to insert non-string keys in namespace dicts that are conceptually string-key only.
>>> globals()[0] = 'zero'
>>> globals()[0]
'zero'
>>> vars()
{'__name__': '__main__', ..., 0: 'zero'}
[This is for consenting adults only, as it prevents sorting keys and string-only operations on keys.
>>> dir()
...
TypeError: '<' not supported between instances of 'int' and 'str']
Do you propose to
1. Only use StringKeyDicts when non-string keys are not possible? (Where would this be?)
2. Switch to a normal dict when a non-string key is added? (But likely not switch back when the last non-string key is removed.)
3. Deprecate and remove the option to add non-string keys to namespace dicts? (Proposed and rejected at least once as not gaining much.) |
|
Date |
User |
Action |
Args |
2022-02-25 21:09:26 | terry.reedy | set | recipients:
+ terry.reedy, rhettinger, methane, Mark.Shannon |
2022-02-25 21:09:26 | terry.reedy | set | messageid: <1645823366.53.0.282544941794.issue46845@roundup.psfhosted.org> |
2022-02-25 21:09:26 | terry.reedy | link | issue46845 messages |
2022-02-25 21:09:26 | terry.reedy | create | |
|