[wingide-users] Telling the Wing Analyzer the type of object withina container?

Wing IDE Support support at wingware.com
Wed Jan 5 08:05:52 MST 2011


We do plan to add tracking of types within containers, though it's not 
something we're working on right now.

Cheers,

John

On 1/4/11 8:32 PM, Jonathan March wrote:
> +1 to the overall goal. I prefer magic comments to assertions.
>
> On Tue, Jan 4, 2011 at 4:49 PM, David Taylor <taylor234 at comcast.net
> <mailto:taylor234 at comcast.net>> wrote:
>
>     +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>
>     [mailto: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 <mailto:wingide-users at wingware.com>
>     *Subject:* [wingide-users] Telling the Wing Analyzer the type of
>     object withina container?
>
>         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...
>
>         ###
>         class PhoneNumber(object):
>            def __init__(self, Type, Number):
>              self.Type = Type
>              self.Number = Number
>
>         class User(object):
>            def __init__(self, Name):
>              self.PhoneNumbers = [] #will be list of PhoneNumber class
>         instances
>
>         fred = User("Fred")
>         fred.PhoneNumbers = [PhoneNumber("work", "555-1212"),
>                               PhoneNumber("home", "555-9876")]
>         ###
>
>         It would be nice if the following line brought up the
>         autocompletion for the PhoneNumber class...
>
>         fred.PhoneNumbers[0].
>
>         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:
>            if 0:
>              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[0], PhoneNumber)
>
>         Or maybe by adding magic Wing comments like this (not fully
>         thought out):
>
>         #WINGTYPE self.PhoneNumbers:list(PhoneNumber)
>
>         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,
>         Russ
>
>
>
>
>
>
>
>
>     _________________________________________________
>     Wing IDE users list
>     http://wingware.com/lists/wingide
>
>
>
>
> _________________________________________________
> Wing IDE users list
> http://wingware.com/lists/wingide



More information about the wingide-users mailing list