Get named module's file location

Roy Smith roy at panix.com
Fri Dec 23 11:18:12 EST 2011


In article 
<32472953.855.1324656114851.JavaMail.geo-discussion-forums at prix23>,
 Gnarlodious <gnarlodious at gmail.com> wrote:

> Given a module's name, how do I get the file path without importing it? 
> Searched all over, can't find any such info.
> 
> Is it possible to ask if a named module exists before attempting an import?
> 
> Or are we forced to import first and catch any failure?
> 
> -- Gnarlie

import imp
imp.find_module()

Why do you want to do this?



More information about the Python-list mailing list