[wingide-users] Better ways to teach the SourceAssistant

Warren, Russell russell.warren at newport.com
Wed Jul 30 15:10:53 MDT 2008

Michael Foord wrote:
> > I have a couple of feature requests for code completion:
> > 
> > * If I use members on an object that Wing doesn't know about, it 
> > should then start offering them to me in code completion. We use 
> > some types with dynamic attributes - and it pains me to repeatedly 
> > type the same member names an Wing still not offer them to me via
> > 
> > * If I have a method that takes a 'worksheet' parameter, and then 
> > use methods on it that are only defined in the 'Worksheet' class, it

> > would be nice if Wing could work out that worksheet is a
John wrote:
> These are good ideas. My current thinking is to have a preference to
> have the auto completer do more guessing and add things like these.
> Right now, the completer is fairly conservative so it doesn't show
> things that may be incorrect.

Wing autocompletion is great, but I too would also like some
improvements.  I have zillions of Wing-assisting lines of code peppered
through my projects like this:

if 0: assert isinstance(foo, bar) #for Wing

Which tells Wing to give me autocompletion on foo as if it were a bar
(even if it isn't).  This is indispensable to me, but I do get tired of
it sometimes.  One tiresome case I can think of is when repeatedly using
a common function that only returns one type.  It would be nice if:

1) Wing knew the return types of the functions in the standard library
 - eg: that os.listdir returns a list

2) There were additional "teaching aids" available to educate the Wing
- eg: A way to tell Wing what return value a function is (or "is like",
if we want to stick with python ducks and avoid people telling me to
switch to a statically typed language!)
- eg: teaching code in comments like:
       "#~Wingdef:os.listdir returns list"

That last example is almost certainly too verbose, but you should get
the idea.

Adding a Wing-specific comment markup is probably going to be frowned
upon, but having more teaching aids than isinstance would be great.
Maybe magic function properties like:

def somefunc():
  """This returns a list"""
  return [1, 2, 3]
if 0:
  somefunc._returns = list #for wing

I'd even be fine with junking my deployed code up with function
decorators to accomplish the same thing, like:

def somefunc():

although that seems less desirable since I can't figure out at the
moment how I would make a decorator that would not get included in
deployed code.

As-is the the source assistant is great... just looking to make it more
so!  It is much improved over a few versions ago and I really appreciate
the feature.  Having it in the python shell is extreeeemely useful, and
when in the debug probe where it is significantly more code aware it is
top notch.


More information about the wingide-users mailing list