[Python-Dev] Incorrect documentation (and possibly implementation) for rlcompleter.Completer? (original) (raw)
Carl Johnson carl at carlsensei.com
Mon Jan 26 01:53:02 CET 2009
- Previous message: [Python-Dev] Changes needed for python-2.6.spec to build successfully
- Next message: [Python-Dev] Incorrect documentation (and possibly implementation) for rlcompleter.Completer?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
The documentation at http://docs.python.org/library/rlcompleter.html
claims that
Completer.complete(text, state)¶
Return the state*th completion for *text. If called for text that doesn’t include a period character ('.'), it will complete from names currently defined in main, builtin and keywords (as defined by the keyword module). If called for a dotted name, it will try to evaluate anything without obvious side-effects (functions will not be evaluated, but it can generate calls to getattr()) up to the last part, and find matches for the rest via the dir() function. Any exception raised during the evaluation of the expression is caught, silenced and None is returned.
In other words, it claims to use dir(obj) as part of the tab
completion process. This is not true (using Python 2.6.1 on OS X):
class B(object): ... def dir(self): return dir(u"") #Makes B objects look like
strings ... b = B() dir(b) ['add', 'class', 'contains', 'delattr', 'doc',
'eq', 'format', 'ge', 'getattribute', 'getitem',
'getnewargs', 'getslice', 'gt', 'hash', 'init',
'le', 'len', 'lt', 'mod', 'mul', 'ne',
'new', 'reduce', 'reduce_ex', 'repr', 'rmod',
'rmul', 'setattr', 'sizeof', 'str',
'subclasshook', '_formatter_field_name_split',
'_formatter_parser', 'capitalize', 'center', 'count', 'decode',
'encode', 'endswith', 'expandtabs', 'find', 'format', 'index',
'isalnum', 'isalpha', 'isdecimal', 'isdigit', 'islower', 'isnumeric',
'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip',
'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition',
'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip',
'swapcase', 'title', 'translate', 'upper', 'zfill'] c = rlcompleter.Completer() c.complete("b.", 0) #Notice that it does NOT return add u'b.class(' c.matches #Notice that this list is completely different from the
list given by dir(b) [u'b.class(', u'b.delattr(', u'b.doc', u'b.format(',
u'b.getattribute(', u'b.hash(', u'b.init(', u'b.new(',
u'b.reduce(', u'b.reduce_ex(', u'b.repr(',
u'b.setattr(', u'b.sizeof(', u'b.str(',
u'b.subclasshook(', u'b.class(', u'b.class(',
u'b.delattr(', u'b.dict', u'b.dir(', u'b.doc',
u'b.format(', u'b.getattribute(', u'b.hash(',
u'b.init(', u'b.module', u'b.new(', u'b.reduce(',
u'b.reduce_ex(', u'b.repr(', u'b.setattr(',
u'b.sizeof(', u'b.str(', u'b.subclasshook(',
u'b.weakref', u'b.class(', u'b.delattr(', u'b.doc',
u'b.format(', u'b.getattribute(', u'b.hash(',
u'b.init(', u'b.new(', u'b.reduce(', u'b.reduce_ex(',
u'b.repr(', u'b.setattr(', u'b.sizeof(', u'b.str(',
u'b.subclasshook(']
As I see it, there are two ways to fix the problem: Change the
documentation or change rlcompleter.Complete. I think the latter
option is preferable (although it might have to wait for Python
2.7/3.1), but I thought I would ask other people if I'm missing
something and if not which fix is preferred. If other people agree
that it's a bug, I'll file it.
-- Carl Johnson
- Previous message: [Python-Dev] Changes needed for python-2.6.spec to build successfully
- Next message: [Python-Dev] Incorrect documentation (and possibly implementation) for rlcompleter.Completer?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]