How to test if a module exists?

Jon Dufresne jon.dufresne at gmail.com
Tue Nov 9 19:08:05 CET 2010


On Mon, Nov 8, 2010 at 11:35 PM, Lawrence D'Oliveiro
<ldo at geek-central.gen.nz> wrote:
> In message <roy-4C92BB.16523506112010 at news.panix.com>, Roy Smith wrote:
>
>> On the other hand, if your module's bug is that it in turn imports some
>> other module, which doesn't exist, you'll also get an ImportError.
>
> Does it really matter? Either way, the module is unusable.

In my program it matters.

If the module exists but is buggy, then I want to be notified
immediately to fix it. However if the module does not exist in an
extension module (keyword being extension) then the extensions doesn't
add behavior to that part of the program.



More information about the Python-list mailing list