[issue40284] Add mapping methods to types.SimpleNamespace

2020-12-21 Thread Raymond Hettinger
Change by Raymond Hettinger : -- stage: -> resolved status: open -> closed ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue40284] Add mapping methods to types.SimpleNamespace

2020-12-21 Thread Raymond Hettinger
Change by Raymond Hettinger : -- resolution: -> rejected ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: htt

[issue40284] Add mapping methods to types.SimpleNamespace

2020-04-20 Thread STINNER Victor
STINNER Victor added the comment: Raymond started a thread on python-dev: https://mail.python.org/archives/list/python-...@python.org/message/JOMND56PJGRN7FQQLLCWONE5Z7R2EKXW/ It seems like most core developers are against modifying types.SimpleNamespace, the trend is more about adding a diff

[issue40284] Add mapping methods to types.SimpleNamespace

2020-04-19 Thread hai shi
Change by hai shi : -- nosy: +shihai1991 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.

[issue40284] Add mapping methods to types.SimpleNamespace

2020-04-15 Thread Vedran Čačić
Vedran Čačić added the comment: I think there is a teaching moment here. I think it's important that no object in Python standard library conflates "item namespace" with "attr namespace". (Maybe that isn't true because of some specialized objects, but surely general ones such as SimpleNamespa

[issue40284] Add mapping methods to types.SimpleNamespace

2020-04-14 Thread Glenn Linderman
Glenn Linderman added the comment: Here's what I have. Maybe it would be better if parse and dump were under or dunder names, although I think parse was in the original implementation I found. Is this the derived from the same original as PyPI dotable? Not sure. -- Added file: https

[issue40284] Add mapping methods to types.SimpleNamespace

2020-04-14 Thread Glenn Linderman
Glenn Linderman added the comment: Yes, I laud this effort. I don't care if it is called SimpleNamespace (which I didn't use because it was insufficient), or anything else, but it would be extremely handy to have this battery. I eventually found one called Dotable (or did I rename it to that

[issue40284] Add mapping methods to types.SimpleNamespace

2020-04-14 Thread Raymond Hettinger
Raymond Hettinger added the comment: > I'm not saying that there is no need for such tool. > I am just asking to leave SimpleNamespace unchanged. I really don't see the downside. It doesn't impair SimpleNamespace in any way. Why would we add another type with substantially the same capabili

[issue40284] Add mapping methods to types.SimpleNamespace

2020-04-14 Thread STINNER Victor
STINNER Victor added the comment: > Providing this tool would instantly benefit a broad class of json users. I'm not saying that there is no need for such tool. I am just asking to leave SimpleNamespace unchanged. -- ___ Python tracker

[issue40284] Add mapping methods to types.SimpleNamespace

2020-04-14 Thread Raymond Hettinger
Raymond Hettinger added the comment: > I would prefer that SimpleNamespace remains as simple as it is This doesn't affect the simplicity of the current API at all. If you don't need the feature, you won't even notice the extension. > If you want to add the mapping protocol, I suggest you to

[issue40284] Add mapping methods to types.SimpleNamespace

2020-04-14 Thread STINNER Victor
STINNER Victor added the comment: I would prefer that SimpleNamespace remains as simple as it is: https://docs.python.org/dev/library/types.html#types.SimpleNamespace "A simple object subclass that provides attribute access to its namespace" If you want to add the mapping protocol, I suggest

[issue40284] Add mapping methods to types.SimpleNamespace

2020-04-14 Thread Raymond Hettinger
Raymond Hettinger added the comment: Only the magic methods need to be added: __getitem__, __setitem__, and __delitem__, __contains__, __len__, and __iter__. The non-dunder names risk incursion into user-space names. >>> SimpleNamespace(username1='value1', username2='value2') namespace(user

[issue40284] Add mapping methods to types.SimpleNamespace

2020-04-14 Thread Raymond Hettinger
New submission from Raymond Hettinger : 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(catal