On Mon, Feb 22, 2021 at 06:26:28PM +1100, Chris Angelico wrote:

> Ultimately, SimpleNamespace is useless if it can't be found.

"Can't" be found is an exaggeration.

The std lib is full of little gems, and people learn them and use them. 
Generally when people talk about something that "can't be found" they 
mean *undocumented* features, like simplegeneric in pkgutil, which 
became the inspiration for functools.singledispatch. (And even then, 
some people obviously did find it.)


> 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.

Of course we can fight human nature. That's what education, school, 
manners, coding standards, documentation, codes of conduct, laws and 
community mores are all about. The fact that hardly anyone chased me 
down the street today with an antelope thighbone to bash my head in is, 
I think, good evidence that we have mostly been successful.

We can't force people to look in `types`, but I don't think that the 
problem is that they refuse to. It's that they don't know about it's 
existence. We don't make everything a builtin because people might not 
know glob; "people don't know about the types module and don't think to 
look in there" is likewise a weak argument for moving SimpleNamespace 
into another module.

It is an argument, but a weak one. Given that SimpleNamespace objects 
aren't a collection, they don't meet the collection API, I think that 
I'm -0.5 on that change.

https://docs.python.org/3/library/collections.abc.html

A Collection is sized, iterable, and supports `in`; SimpleNamespace 
supports none of those.
_______________________________________________
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/IHTUMKGS6HZNMUGCJJKXBIMCJ3C3GTIZ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to