[wingide-users] Silly question about the parameters
support at wingware.com
Wed Mar 2 10:10:21 MST 2011
On 3/2/11 11:51 AM, Cesco wrote:
> Is there a way to declare in WingIDE that a certain parameter used in a function is an instance of something, in order to have the code intelligence working?
Yes, you can do this:
Or if you want to actually check the truth of that when running Python
in debug mode (w/o the -O or -OO command line arg) you can do:
assert isinstance(mydate, datetime.datetime)
(assert goes away entirely when using -O or -OO)
> In Java, C#, VB.Net or any other language you don't have this problem, because (AFAIK... don't kill me if'm mistaken:) they're strongly-typed languages, ...
Python is actually also strongly-typed but it is not statically typed so
you can't necessarily know the types of things until runtime except
through inference. This is a subtle distinction, of course, and mostly
only language designers will care about.
BTW, setting a breakpoint and debugging to it is a way to get runtime
type information in the editor. Wing uses the runtime type info when
available (if the code being edited is somewhere on the debug stack in
the paused debug process). The Debug Probe does this also, for the
currently selected debug stack frame. I tend to use those capabilities
rather than sprinkling isinstances all over the place. I do use them
for class/instance attributes because you get more mileage out of those,
but doing it in every function isn't usually worth it.
Wingware | Python IDE
Advancing Software Development
More information about the wingide-users