Jim Fulton
Tim Peters wrote:
[Jim Fulton] ...
No, it won't. For example, suppose foo imports B. B tries to import C, but fails. B is now broken, but it is still importable. Actually, both foo and B can be imported without errors, even though they are broken. Then you're proposing a way for a highly knowledgable user to anticipate, and partially worm around, that Python leaves behind insane module objects in sys.modules.
No. I'm proposing a way for a Python developer to detect the presence or absence of a module.
Hm, perhaps it would be better to provide an API (if there isn't one already) to test whether a module is present.
Doesn't imp.find_module do this? On Windows:
import imp imp.find_module("termios") Traceback (most recent call last): File "<stdin>", line 1, in ? ImportError: No module named termios imp.find_module("pty") (
, 'c:\\python23\\lib\\pty.py', ('.py', ^Z
Thomas