optional static typing for Python
Arnaud Delobelle
arnodel at googlemail.com
Mon Jan 28 15:19:24 EST 2008
On Jan 28, 4:31 pm, John Nagle <na... at animats.com> wrote:
> Arnaud Delobelle wrote:
[...]
> > 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.
>
> Unenforced static typing is somewhat pointless. If that
> goes in, it should be enforced by implementations. Otherwise,
> maintenance programmers can't trust the type information they see.
(As discussed earlier, there is no static typing in Python, there can
only be runtime type-checking or, as someone called it, "explicit
typing")
I think the idea is to let the user decide how to enforce type-
checking, not the language. I suppose if in a few years a way to do
it emerges that is "the best", then it'll make its way into the
standard library...
--
Arnaud
More information about the Python-list
mailing list