Hello, On Sun, 21 Feb 2021 16:51:37 -0800 Brendan Barnwell <brenb...@brenbarn.net> wrote:
> On 2021-02-17 11:21, Chris Angelico wrote: > > Okay. Let's start bikeshedding. If SimpleNamespace were to become a > > builtin, what should its name be? It needs to be short (obviously), > > but not TOO short, and it needs to be at least somewhat descriptive, > > and it needs to not cause confusion with "object". Ideally, it > > should get a name that's unlikely to conflict with names already in > > frequent use. > > Thinking about this more, I think the main obstacle to use of > SimpleNamespace isn't the name, it's its the location. No one is > going to look in the types module for something like this. Well, they should (start to look around). > Why not just put SimpleNamespace in the collections module? > The one in types could be aliased to it (or vice versa if we really > don't want to change anything). That seems like it's a trivial > change that would greatly increase discoverability of SimpleNamespace > without adding complexity of any kind. 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. It doesn't "contain" things (no more than overdynamic mata-protocols allow, and those are implementation details). It "holds" things. It's, well, just a simple namespace. But seems that people mix up it with that thingy which allows ambiguous access both by a key indexing and attribute access. And that puts SimpleNamespace in danger, because after "let's munge its name/location" requests, what will follow is "let's add unrelated methods to it". But I agree that putting it in "collections" is an interesting plot twist. We already gave up hope for "types", and knowing that it contains lotsa mess, simply don't look for pearls which may be there. Let's now do the same to "collections". [] -- Best regards, Paul mailto:pmis...@gmail.com _______________________________________________ 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/E2ZWRKXAFRBBEDHDSDGDJHLPJTIJ5KLM/ Code of Conduct: http://python.org/psf/codeofconduct/