Gabriel Genellina <gagsl-...@yahoo.com.ar> added the comment: This is not a bug in rlcompleter; __dir__ is returning bogus items, and rlcompleter checks whether there exist actually an attribute with such name.
Defining __getattr__ (or __getattribute__) and a matching __dir__ works fine: >>> class B(object): ... def __dir__(self): ... return dir(object) + ["xa","xb","xc"] ... def __getattr__(self, name): ... if name in ["xa","xb","xc"]: ... return None ... raise AttributeError, name ... >>> b = B() >>> import rlcompleter >>> c = rlcompleter.Completer() >>> c.complete("b.", 0) 'b.__class__(' >>> c.matches ['b.__class__(', 'b.__delattr__(', 'b.__doc__', 'b.__format__(', 'b.__getattribute__(', ... 'b.xa', 'b.xb', 'b.xc', 'b.__class__(', 'b.__class__(', ...] >>> c.complete("b.x", 0) 'b.xa' >>> c.matches ['b.xa', 'b.xb', 'b.xc'] Now, looking at this I saw there *is* a bug in rlcompleter, as it may return many duplicate items: >>> c.complete("b.__c", 0) 'b.__class__(' >>> c.matches ['b.__class__(', 'b.__class__(', 'b.__class__(', 'b.__class__('] The attached patch fixes that. ---------- keywords: +patch nosy: +gagenellina Added file: http://bugs.python.org/file12872/rlcompleter.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue5062> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com