Module name to filename and back?

Ron Adam rrr at ronadam.com
Thu Jan 18 16:57:42 CET 2007


Is there a function to find a filename from a dotted module (or package) name 
without importing it?

The imp function find_module() doesn't work with dotted file names.  And it 
looks like it may import the file as it raises an ImportError error exception if 
  it can't find the module. (Shouldn't it raise an IOError instead?)

What I'm looking for is to be able to get the full module name when I have a 
filename.  And get the full filename when I have the module name.  And do both 
of these without importing the module.

    modulename <==> filename
    filename <==> modulename

Ron





More information about the Python-list mailing list