On Mon, Feb 22, 2021 at 6:08 PM Paul Sokolovsky <pmis...@gmail.com> wrote: > One explanation why SimpleNamespace is not in "collections" is because > ... it's not a collection. One of the basic traits of any collection is > that it "contains" things, and thus it can be directly iterated over to > traverse those contents: > > for item in collection: ... > > SimpleNamespace is not like that.
So it's not iterable. But does everything HAVE to be iterable to go into that module? UserString technically is, but I don't think it's there to function as an iterable - it's there to function as a string. (TBH I think that UserDict/UserList/UserString would probably fit better into types than collections.) One very common use for SimpleNamespace is a sort of "generic record type", kinda like a namedtuple but minus the iteration and without needing to predefine the attributes. Placing it alongside namedtuple will make that easier to work with. OTOH, that also makes it kinda like a generic dataclass, but this isn't going to go into the dataclasses module, so I'm not sure how strong an argument that is. Ultimately, SimpleNamespace is useless if it can't be found. If people looking for this are not going to look in types, then either people need to be educated (good luck with that - you can't fight human nature), or it needs to be placed where people will find it. ChrisA _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/D65GOWPLJJSSE7ACAMHJMAFX6L2LWO77/ Code of Conduct: http://python.org/psf/codeofconduct/