'Intellisense' possible for Python?

Greg Brunet gbrunet at nospamsempersoft.com
Wed Dec 18 20:52:16 EST 2002


Thanks for the response & points!

"Peter Hansen" <peter at engcorp.com> wrote in message
news:3E00F4F5.11997662 at engcorp.com...
> 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.

Understood - in fact in VB Script, all variables are untyped (though
they can be declared (without a type), which helps catch some errors).
However, I would argue that for most code, a variable will keep the same
type of information in each pass. (I would expect a loop counter to
always contain an integer or a long each time that section of code is
executed).  I realize that it's highly unlikely for Python to change and
_require_ variable declaration, but it it allowed it, which seemed to be
under consideration in the articles I found, then it would be possible
to

>
> 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...

In a situation like this, where you have an untyped parameter, I
wouldn't expect the 'Intellisense' to provide any methods (unless there
are some base methods that all Python objects implement).  For example
in VB.NET, an 'untyped' variable would be declared an Object.  If I
typed "o." in the IDE, the only method choice that I would see is
"GetType".  However if I defined i as an Integer, then I'd have
additional methods and properties that would appear, like ToString,
MinValue, MaxValue, etc.  Obviously this is pretty simplistic.  It
really pays off when you need to start dealing with large class
libraries where you aren't constantly using all of the elements.  A good
example is a GUI framework - I've started looking into wxPython, and
since it maps closely to what I'm used to in Windows development, I have
a good idea on what to expect, but I'm still spending a lot of time
going back & forth into the help files to find the right method to use
or the right parameters to pass.  I'm just looking for something that
would be better integrated into the IDE so it is more readily available.

--
Greg




More information about the Python-list mailing list