On Wed, Dec 30, 2020 at 5:01 PM Steven D'Aprano email@example.com wrote:
Speaking of slots, I've often been annoyed that there is no abstraction that hides the difference between instances that use a dict as symbol table, and those that use slots. (And those that use both.)
it would be nice to
ignore the implementation details and just have a "symbol table" object to work with. What do you think?
I think that would be great -- and wonder if vars() could be extended to do that?
Do you prefer to write `mylist.__len__()` over `len(mylist)`? Then you
will probably prefer `obj.__dict__` over `vars(obj)` too :-)
Not a valid analogy.
I think it is. Apart from a matter of taste, what part of the analogy do you feel is invalid?
For my part, I think the difference is that when you are working with .__dict__ you are doing meta-programming, for which poking around in the dunders makes perfect sense.