[wingide-users] method completion

Wingware Support support at wingware.com
Mon Mar 13 11:42:07 EST 2006


On Mon, 13 Mar 2006, Walker Hale wrote:
> The "if 0" part of the idiom restores duck typing. The assertion is not
> actually run at runtime, since 0 is always construed as false. It just
> serves to tell the Wing about the type of the object. (It may also insert a
> tiny amount of unused byte code into your compiled files.)
>
> This idiom is also in the Wing docs. It is a Good Thing (tm). If you need
> it, use it.
>
> if 0:
>    assert isinstance( myObject, theType )

It's also useful if you need to say isinstance(x, 
mymodule.mytype) and importing mymodule results in a circular 
reference.

Internally we tend to omit the 'if 0' if we're not running into 
that and not doing duck typing.  May as well have the extra 
runtime check.

But Wing doesn't care which you do, it's a personal choice.

- Stephan


More information about the wingide-users mailing list