>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/) 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