rlcompleter and wxPython, problems ...
gagsl-py2 at yahoo.com.ar
Tue Sep 30 22:07:46 CEST 2008
En Tue, 30 Sep 2008 16:06:07 -0300, Stef Mientki <stef.mientki at gmail.com>
> Gabriel Genellina wrote:
>> En Sun, 28 Sep 2008 19:25:30 -0300, Stef Mientki
>> <stef.mientki at gmail.com> escribió:
>>> I'm trying to implement autocompletion into my editor.
>>> But I find some weird behavior,
>>> or at least I don't have the faintest idea why this behavior occures,
>>> and even more important how to solve it
>>> In the example below I try to autocomplete " wx.s" , which in my
>>> humble opinion should at least produce "wx.stc" (and some others ).
>> wx is a package. Modules within the package are not, by default,
>> attributes of the package - unless they're imported in __init__.py or
>> your code imports them.
>> So the autocompleter is doing the right thing
> in what perspective ?
> the autocompleter is only meant to assist the program writer ;-)
It's hard to write an autocompleter that does the right thing in all cases
For a package, you have several sources for possibly valid attributes:
- its dir() (that is, the package object's own attributes)
- the __all__ attribute, when it exists
- the list of modules inside the package directory or directories (given
by its __path__ attribute)
Sometimes __init__.py is empty - and enumerating the modules inside the
directory is the right thing to do. Sometimes the author explicitely
imports things in __init__.py, things that comprise the public interfase
to the package. In that case I'd not like to see "private" modules
appearing in the list.
Combine with __all__, which might be defined or not. Mix all those, choose
your own autocomplete algorithm, and see what happens...
>> - wx.stc does not exist until it is explicitely imported.
> I guess I've to study the package.
> For the moment I'll implement a user editable list of additions.
> But with your remarks I tried __all__
> And now I wonder why rlcompleter is not simply using "wx.__all__",
> it than does gets all the items ?
__all__ isn't always defined. It's only used when you do "from xxx import
More information about the Python-list