Python editor example with auto-complete?
holger krekel
pyth at devel.trillke.net
Tue Dec 10 13:46:14 EST 2002
Robert Oschler wrote:
> Has anybody seen a python example that had auto-complete built in? It seems
> like it wouldn't be a horrendous job to provide at least current class level
> only auto-complete for methods and attributes.
the standardlibs 'rlcompleter' does this but in a limited way. I am
about to release a substitute version this week ...
> By auto-complete I mean, you're in an edit window.
Yeah, would be fun to have autocompletion in edit windows.
I guess it would increase productitvity by 30% (or more at least
for me). But it is hard and here is why.
Autocompletion has to examine objects at runtime to find
attribute names. On a single commandline this is relatively
straightforward because the python commandline really is an
*execution* environment: You can parse a commandline and
relate the names in your command to the runtime environment.
If you are inside an editor you are *not* in the runtime environment
of the program. Parsing python syntax gets you no clue
about the actual objects and its type. That's why it is called
'dynamic typing'. Not static type declaration: it is not enough
for an editor to only parse source code to get to autocompletion
information. It requires *execution* in order to know which
object a name refers to.
To summarize, an editing facility needs to be connected to
the runtime execution of your program to give you autocompletion.
Michael Hudson's pyrepl, Fernando Perez' IPython and my
'rlcompleter2.py' aim in this direction. While Michael's
pyrepl does multiline editing my stuff handles all python
statements/expressions and additionally provides runtime
documentation introspection.
regards,
holger
More information about the Python-list
mailing list