Typed Python?

John Roth newsgroups at jhrothjr.com
Sat Jul 3 06:59:55 EDT 2004


"Thomas Reichelt" <XXNOSPAMXX at gibts.net> wrote in message
news:2kn746F4ci1vU1 at uni-berlin.de...
> Moin,
>
> short question: is there any language combining the syntax, flexibility
and
> great programming experience of Python with static typing? Is there a
> project to add static typing to Python?

I believe that it's on Guido's wish list, at least as an option.
At one time there was a types sig that was looking into it,
but I don't know of its current status. It got bogged down
and didn't deliver anything.

There are a couple of projects that have done some kind
of type inference in Python. You might check out Bicycle
Repair Man, which has a type inference engine that it uses
to help in refactoring. I've also heard of another academic
project that was supposed to release code sometime this
summer, but the name escapes me.

There are a number of places that would have to be cleaned
up to make type inference work well. The <string>.find() method
is practically a poster child for a method that would give any
type inference mechanism fits. It returns an integer, right?
Wrong. It's supposed to return either an index into the string
(a separate type) or an indication it didn't find one. However,
the result sometimes evaluates to False when it found one,
always evaluates to True when it didn't, and is a valid index
even when it didn't find a match.

A <string>.findall() method that returned a list of all
matches is much cleaner: it evalutes to false when the
list is empty (no matches), it never returns something
that looks like an index for a non-match, and it's
compatible with the for statement.

John Roth
>
> Thank you,
>
> -- 
> greetz tom





More information about the Python-list mailing list