len() is an important abstraction for containers, and its usage deserves a short name (just like unary minus and abs() for numbers). This is crucial even though >you have to use its "true name" (https://xkcd.com/2381/<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fxkcd.com%2F2381%2F&data=04%7C01%7C%7C3f1cdaa1afa74e3eaac908d8ad48ede4%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637449876024295719%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=rmre4UOxKowtUhZF7Ug79mYEvM6rgRGBeemtNJ6XtZo%3D&reserved=0>) to define the implementation for a particular class.
OTOH, `__dict__` is the opposite of an abstraction -- whether you spell it vars(x) or `x.__dict__`, the matter remains that you're looking inside the >implementation of the object, and what you get is not an abstraction -- as you've pointed out for `__slots__`, and as is also apparent for e.g. namedtuple or >fundamental objects like numbers, strings and built-in container types.
By making the dominant spelling `__dict__`, we remind people that when they use this, they're tinkering with the implementation. Don't get me wrong, this >can be fun and useful, but it's not a clean abstraction. The more fundamental abstraction is getattr()/setattr(), since it is supported by *all* objects, not just >most classes.
Can I suggest that a missing component is lsattr() as a similar function to dir() but with a guarantee that everything returned will succeed if used for a getattr call - possibly without a guarantee that it will list everything that will successfully return from getattr e.g. if there is a custom getattr that does a case independent search so that if getattr for spam, Spam and SPAM all return spam lsattr would only return spam but if there is a local attribute eggs that getattr excludes so would lsattr. It would also be nice if it had a flag, (possibly defaulting to true), to exclude all entries with a leading underscore. (Personally I think that this would be a handy option for dir() as well). Steve (Gadget) Barnes