27 Jul
2004
27 Jul
'04
8:44 p.m.
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.
AFAIK, the only way to do it is by trying the import. Unfortunately, the error type alone isn't enough to tell whether the error you caught is due to the error condition you are trying to test.
Perhaps providing an API is a better way to go.
This exists as imp.find_module.
In general, however, I hate the approach of formatting errors as they are raised, rather than as they are converted to strings.
Agreed. --Guido van Rossum (home page: http://www.python.org/~guido/)