[New-bugs-announce] [issue40284] Add mapping methods to types.SimpleNamespace
Raymond Hettinger
report at bugs.python.org
Tue Apr 14 17:10:49 EDT 2020
New submission from Raymond Hettinger <raymond.hettinger at gmail.com>:
types.SimpleNamespace() would be much more usable if it were more substitutable for dictionaries. In particular, it would be wonderful to be able to use object_hook=SimpleNamespace in json.load():
Current:
catalog = json.load(f)
print(catalog['clothing']['mens']['shoes']['extra_wide']['quantity'])
Proposed:
catalog = json.load(f, object_hook=SimpleNamespace)
print(catalog.clothing.mens.shoes.extra_wide.quantity])
----------
components: Library (Lib)
messages: 366447
nosy: rhettinger
priority: normal
severity: normal
status: open
title: Add mapping methods to types.SimpleNamespace
versions: Python 3.9
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40284>
_______________________________________
More information about the New-bugs-announce
mailing list