'Intellisense' possible for Python?

Peter Hansen peter at engcorp.com
Wed Dec 18 17:21:41 EST 2002


Greg Brunet wrote:
> 
> Coming from a VB background where the IDE allows you to view &
> auto-complete all of the properties & methods of an object, it's
> disappointing not to have it - at least in the IDE's I've looked into so
> far.  While I get this kind of behavior for modules in PythonWin
> (automatically) and Boa Constructor (by pressing Ctrl-Space), it doesn't
> work for variables.  Is this even possible, given that Python doesn't
> declare it's variable?  Does anyone know of an IDE that supports it?

The problem is not that Python doesn't "declare" its variables, so much
as that in Python, variables *do not have a type*.  The data/objects to
which variable names are bound do have type, but those types cannot be
known reliably until runtime, and in fact could change from one pass
through a given line of code to the next.

def printit(x):
    print 'output: %s' % (x,)

printit('test')
printit(5)
class A:
    def __str__(self):
        return 'an A'
printit(A())

If you were editing code inside the printit() function, how could
an IDE know what to display for the methods of an object?  Anything
can be passed in...

Maybe an IDE could make an educated guess, based on recent code
patterns, but at the very least this cannot always work, and it
could be fairly limited in what it can do.... how often do you 
refer to an object immediately after creating it, versus working
with an object that was created elsewhere and passed in from outside
the current context?  Probably rarely...

-Peter



More information about the Python-list mailing list