optional static typing for Python

Kay Schluehr kay.schluehr at gmx.net
Sun Jan 27 22:40:40 EST 2008


On Jan 28, 12:22 am, Arnaud Delobelle <arno... at googlemail.com> wrote:
> On Jan 27, 11:00 pm, "Russ P." <Russ.Paie... at gmail.com> wrote:
>
> > On Jan 27, 2:49 pm, "André" <andre.robe... at gmail.com> wrote:
> > > Perhaps this:http://www.python.org/dev/peps/pep-3107/mightbe
> > > relevant?
> > > André
>
> > Thanks. If I read this correctly, this PEP is on track for Python 3.0.
> > Wonderful!
>
> Note that annotations do not provide explicit typing, AFAIK:
>
> def f(x:int) -> int: return x*2
>
> is stricly equivalent to
>
> def f(x): return x*2
> f.__annotations__ = {'x':int, 'return':int}
>
> You still need to write a type-checking wrapper.

Has anyone figured out how to match arguments passed into a "wrapper"
function defined within a decorator onto the signature of f or onto
f.__annotations__ respectively?

> PEP 3107 mentions two
> such tools:
> *http://oakwinter.com/code/typecheck/
> *http://maxrepo.info/taxonomy/term/3,6/all
> Neither require annotations.

I like the design of the typecheck package. Everying is implemented in
__init__.py ;)



More information about the Python-list mailing list