[wingide-users] Telling the Wing Analyzer the type of object
taylor234 at comcast.net
Tue Jan 4 15:49:40 MST 2011
+1, tho I have no better ideas on how to give the hint to Wing.
From: wingide-users-bounces at wingware.com
[mailto:wingide-users-bounces at wingware.com] On Behalf Of Russell Warren
Sent: Tuesday, January 04, 2011 10:34 AM
To: wingide-users at wingware.com
Subject: [wingide-users] Telling the Wing Analyzer the type of object
I'm sure I know the answer, but is there any way to tell the Wing Analyzer
the "likely type" of objects within a container?
A small example...
def __init__(self, Type, Number):
self.Type = Type
self.Number = Number
def __init__(self, Name):
self.PhoneNumbers =  #will be list of PhoneNumber class instances
fred = User("Fred")
fred.PhoneNumbers = [PhoneNumber("work", "555-1212"),
It would be nice if the following line brought up the autocompletion for the
but it does not.
This is clearly hard for Wing to figure out, and I often do the recommended
coaching like this:
for pn in fred.PhoneNumbers:
assert isinstance(pn, PhoneNumber)
print "%s: %s" % (pn.Type, pn.
which works well as it is supposed to, but I end up having a LOT of these
throughout my code. What would be much nicer is if I could inform Wing what
the likely type is that will be contained in the list (or other container)
at definition time rather than at access time.
Since I expect that this is not currently possible, I'll suggest two ways
this might be coachable. One fits the current "no magic Wing code needed"
mold and just tells Wing the type of one element in the container, with Wing
assuming the rest are the same type. eg:
assert isinstance(self.PhoneNumbers, PhoneNumber)
Or maybe by adding magic Wing comments like this (not fully thought out):
Containers obviously don't always have a uniform type in them, but they
often do and I often desperately want this feature. Where it happens a lot
is with an ORM and a one-many relationship where you end up with zillions of
lists of various complex classes. Telling Wing what class interface is best
to display for the autocompletion of a list element would be really great.
Thanks for reading,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the wingide-users