finding pathname from within a module?

Alex Rice alex at integretechpub.com
Thu Sep 13 15:24:53 EDT 2001


On Thu, 13 Sep 2001 brueckd at tbye.com wrote:

> > Is there a way to do something like <thecurrentmodule>.__path__?
> 
> import imp, os
> path = imp.find_module('yourmodule')[1]
> filename = os.path.join(os.path.split(path)[0], 'datafilename')

Thanks- I didn't know about the imp module. This is what I'm using now:
I've verified this works within the module being defined- which is exactly
what I needed.

fileName = os.path.join(imp.find_module('mymodule')[1],'myfilename')

Alex






More information about the Python-list mailing list