> To bad that removing the * from the import statement would be a major
> change in the language and would break just about everyones code.
> Being able to write a static type checker for Python is a key
> requirement for some application domains. Is there more than just the
> * that makes static checking impractical?
Actually I don't think that "from X import *" makes static type
checking impractical. It just means that you have to analyze module X
to find out what symbols it defines before you can continue analyzing
the current module, but you need that anyway: after
from USA import SPAM
SPAM()
you will have to analyze the USA module anyway before you can tell
whether SPAM() is safe.
In fact analyzing which symbols a module defines is fairly easy (it
could be done using the same method that determines local variables
for a function). One assumption that static type checks for Python
will have to make anyway is that a module isn't modified by
assignments like
USA.SPAM = "something completely different"
in an unrelated part of the program -- but that's just (yet) another
job of static type checking.
--Guido van Rossum, CWI, Amsterdam <mailto:Guido.van.Rossum@cwi.nl>
<http://www.cwi.nl/cwi/people/Guido.van.Rossum.html>