list of attributes

Ken ken at seehart.com
Sat Mar 8 01:58:23 EST 2008


I have a class with a __getattr__ method that returns various methods.  
I also have the ability to determine the list of method names that are 
supported by my __getattr__ method (this list would be dynamically 
generated as it depends on the current state).

What I would like to know is if there is a way overload the behavior of 
dir(instance) to include this dynamically generated list of method 
names.  Ideally this would have the effect of making these methods 
visible to the autocomplete feature of debuggers in most modern IDEs.

It looks like this would be __dir__ in 2.6, is that right?

Ken




More information about the Python-list mailing list