Test for the existence of a module without actually importing it.
We could just do
try:
import modName
except ImportError:
...
except that that has the potential to hide other errors.
Definition at line 13 of file moduleExists.py.
13def moduleExists (modName):
14 """Test for the existence of a module without actually importing it.
15
16We could just do
17 try:
18 import modName
19 except ImportError:
20 ...
21except that that has the potential to hide other errors."""
22
23 return importlib.util.find_spec (modName) is not None