Metaclass conundrum - binding value from an outer scope

Skip Montanaro skip.montanaro at gmail.com
Fri Apr 21 08:26:52 EDT 2017


On Thu, Apr 20, 2017 at 3:19 PM, Peter Otten <__peter__ at web.de> wrote:

> If being helpful really is the only purpose of the metaclass you can
> implement a SomeClass.__dir__() method instead:
>
>      def __dir__(self):
>          names = dir(self._instance)
>          # <snip whatever post-processing you want>
>          return names
>

Thanks. That would probably get me halfway home in Python 3, but appears to
have no effect in Python 2. It wouldn't solve the missing attributes in
help()/pydoc either.

Skip


More information about the Python-list mailing list