[IPython-User] Tab completion doesn't work on class/instance where __getattr__ has been overridden
Jörgen Stenarson
jorgen.stenarson@bostream...
Tue Mar 1 16:11:31 CST 2011
Jeremy Conlin skrev 2011-03-01 20:58:
> I have a class (subclassed from list) where I have overwridden the
> __getattr__ method as:
>
> def __getattr__(self, name):
> if name.startswith("__"): raise AttributeError
> def _multiplexed(*args, **kwargs):
> return [getattr(R, name)(*args, **kwargs) for R in self]
> return _multiplexed
>
> Now when I try to use tab completion, iPython just beeps at me and
> doesn't complete anything. If I remove this method from my class, I
> can do tab completion.
>
> Does the tab completion use __getattr__ somewhere? Can I add
> something to my definition to make tab completion work in iPython?
>
One way to customize which attributes are found by the completer is to
define the __dir__ method which essentially defines what should be
returned by a dir call.
/Jörgen
More information about the IPython-User
mailing list