[wingide-users] RE: What doc tool do you use?

Jason L Connor jconnor at redhat.com
Thu Oct 6 13:05:55 MDT 2011


On Thu, 2011-10-06 at 08:37 +0200, Linos wrote:
> El 05/10/11 21:46, Wing IDE Support escribió:
> > On 10/5/11 2:02 PM, Linos wrote:
> >> In the meantime can i use .pi files to declare method signatures and variables?
> >> if so what syntax do i have to use to declare this:
> >>
> >> file test.py:
> >> class test(object):
> >>     def __init__(self, par1, par2):
> >>         var1 = complicated_and_long_func()
> > 
> > Put a test.pi file in the same directory with (assuming everything is a str for
> > purposes of the example):
> > 
> > class test(object):
> >     def __init__(self, par1, par2):
> >         isinstance(var1, str)
> >         isinstance(par1, str)
> >         isinstance(par2, str)
> > 
> > Note that this was implemented primarily for another use case, so this probably
> > won't be the recommended way of doing things if we implement support for other
> > type hints but it works now.  I'm personally not a fan of having multiple files
> > for one module.
> > 
> > Cheers,
> > 
> > John
> 
> I am not a fan either but until Wing IDE supports other inline syntax type hints
> i prefer this to fill my code with false isinstance calls. Thanks.
> 
> Un saludo,
> Miguel Ángel.

One trick I use is to put the isinstance calls in asserts:

class test(object):
    def __init__(self, par1, par2):
        assert(isinstance(par1, str))
	assert(isinstance(par2, str))
        # rest of constructor
        ...

That when I distribute .pyo files, the asserts are stripped out and when
I run in development from .pyc files, they're executed.

Maybe not everyone's taste, but it solves a lot of precondition
enforcement issues while running as a developer and helps wing's
introspection at the same time.

-- 
Jason L Connor
linear on freenode #pulp
http://pulpproject.org/
RHCE: 805010912355231
GPG Fingerprint: 2048R/CC4ED7C1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: This is a digitally signed message part
Url : /pipermail/wingide-users/attachments/20111006/76239b10/attachment.bin


More information about the wingide-users mailing list