[IPython-User] Tab completion doesn't work on class/instance where __getattr__ has been overridden
Robert Kern
robert.kern@gmail....
Tue Mar 1 17:43:47 CST 2011
On 3/1/11 1:58 PM, Jeremy Conlin wrote:
> 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?
It works for me with the HEAD of IPython. What version are you using?
[~]
|8> class A(list):
..> def __getattr__(self, name):
..> if name.startswith('__'): raise AttributeError
..> return 10
..>
[~]
|9> a = A()
[~]
|10> a.
a.append a.extend a.insert a.remove a.sort
a.count a.index a.pop a.reverse
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the IPython-User
mailing list