[Python-ideas] Implementing __dir__ (moving dir implementation to object.__dir__?)

Steven D'Aprano steve at pearwood.info
Tue May 24 01:58:23 CEST 2011


On Tue, 24 May 2011 04:16:44 am Michael Foord wrote:
> Hello all,
>
> I'm looking at implementing __dir__ for a class (mock.Mock as it
> happens) to include some dynamically added attributes, the canonical
> use case according to the documentation:
[...]
> Moving the relevant parts of the implementation of dir into
> object.__dir__ would be one way to solve that.

I haven't yet needed to write a custom __dir__, but your proposal makes 
sense to me.

+1


-- 
Steven D'Aprano



More information about the Python-ideas mailing list