looking for standard/builtin dict-like data object
kmisoft at gmail.com
Tue Aug 11 14:06:05 CEST 2015
>>> I also thought the stdlib had some kind of "namespace" class with this
>>> of API, but I can't find it now:-(
>> It does - types.SimpleNamespace(). It accepts keyword arguments, and
>> will let you create more attributes on the fly (unlike a namedtuple).
> Yes, that's it. Thanks!
Ah, sad, sad, sad. We unfortunately stuck with built-in Python 2.6.x
in our system. I see from docs that SimpleNamespace is rather new
creation (3.3+). I know 'namedtuple' way, but don't like it as I
prefer freedom in attribute creation/mutation. Looks like I have to
stuck with handmade solution for now.
Anyway - thanks a lot for everybody!
More information about the Python-list