On Wed, Dec 30, 2020 at 5:01 PM Steven D'Aprano <st...@pearwood.info> 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.) <snip> 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. -CHB -- Christopher Barker, PhD Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython
_______________________________________________ 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/TW455VM46BHIIUTR6SBF4SHCRY4EUL3Y/ Code of Conduct: http://python.org/psf/codeofconduct/