Get named module's file location

Yaşar Arabacı yasar11732 at gmail.com
Fri Dec 23 11:16:37 EST 2011


>>> import imp
>>> imp.find_module("os")
(<open file '/usr/lib/python2.7/os.py', mode 'U' at 0xb6c4c700>,
'/usr/lib/python2.7/os.py', ('.py', 'U', 1))
>>>

2011/12/23 Gnarlodious <gnarlodious at gmail.com>

> 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
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
http://yasar.serveblog.net/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20111223/ef6dcb5b/attachment-0001.html>


More information about the Python-list mailing list