[Jim Fulton] > ... > No. I'm proposing a way for a Python developer to detect the > presence or absence of a module. Seems to me a module is present if and only if you try to import it, and the import succeeds, or the import fails and the module name is in sys.modules after. >>> import cupcake # no such thing Traceback (most recent call last): File "<stdin>", line 1, in ? ImportError: No module named cupcake >>> 'cupcake' in sys.modules False >>> >>> import pty # exists, but is broken on Windows Traceback (most recent call last): File "<stdin>", line 1, in ? File "C:\Program Files\Zope-2.7.2-0\bin\Lib\pty.py", line 19, in ? import termios ImportError: No module named termios >>> 'pty' in sys.modules True >>> Not that I like this -- it turns broken modules into "a feature". A function that answered the question directly would be mounds better.
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