On 16 June 2017 at 07:44, Barry Scott <ba...@barrys-emacs.org> wrote: > But I need the result of __dir__ for my object not its base. Then I need to > add in the list of member attributes that are missing because python > itself has no knowledge of them they are accessed via getattr().
The C code: dir_result = PyObject_CallMethod(base_type, "__dir__", "O", self); is roughly equivalent to the Python code: dir_result = BaseType.__dir__(self) That is, it's calling the base type's __dir__ method, but it's still using the subclass *instance*. It's the same pattern people use to call a base type's __getattr__ or __getattribute__ for the subclass implementation of those methods, just without multiple inheritance support (since calling super() from C is painful). Cheers, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/