Jim Fulton <jim at zope.com> writes: > 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") (<open file 'c:\python23\lib\pty.py', mode 'U' at 0x00981760>, 'c:\\python23\\lib\\pty.py', ('.py', >>> ^Z Thomas
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4