Adding static typing to Python

logistix logstx at bellatlantic.net
Mon Feb 18 20:09:35 EST 2002


Do I understand you correctly? You're worried that a dynamic language won't
throw a compiler error if you change a method name?

That's what grep and "Find in Files..." is for. ;)

Seriously though, from a testing perspective you could have a test function
like legacyMethods() that actually scans the source code old method names,
instead of trying to climb through the codebase until an error shows up.
Lint (for C, not python) is an example of a program that tests for logic
bugs at the source code level.

You could also do stuff along the lines of

def oldMethod(self):
    raise RuntimeError, "oldMethod() no longer supported, use newMethod()"

def newMethod(self):
    pass

This will at least force your code to break in a predictable way, instead of
introducting vague and unpredictable errors.


--
-

"Alexander Jerusalem" <ajeru at vknn.org> wrote in message
news:24c39b2c.0202181531.187fad4c at posting.google.com...
> Has anyone heard of plans to add static type checking to Python? I
> like Python very much but I don't use it for bigger projects because I
> fear the testing effort. For example I just refactored a rather large
> Java codebase. And when I change a method name for example, all I have
> to do is run everything thru the compiler and it will show me all
> places in other classes where this method is called, so I can go there
> and chenge the method call as well.
>
> In Python I'd have to test the whole software suite including each and
> every branch in each and every if statement to be sure that I didn't
> forget something. To build such a test suite would take almost as long
> as it takes to build the whole software and I'd have to maintain the
> test suite as well. That's just unafordable.
>
> On the other hand, Python is the best language that currently exists
> and I would like to use it on bigger projects not just for prototyping
> as some suggest.
>
> Regards,
> Alexander Jerusalem





More information about the Python-list mailing list