location of a module's directory
Joonas Paalasmaa
joonas at olen.to
Fri Apr 5 10:03:05 EST 2002
Dave Berkeley wrote:
> Is there a way to discover where a module was loaded from?
>
> I want to include a text configuration file with a .dll, and place them in
> the same directory. If the module knows where it was loaded from it will be
> able to find the config file.
>
> If you do (Python 2.1.1)
>
>
>>import sys
>>print sys.modules
>
>
> you can get a dictionary of loaded modules, and a description, which
> includes the path the module was loaded from. However, I can find no way of
> accessing this information programmatically.
Are you looking for this?
Python 2.2a3 (#23, Sep 7 2001, 01:43:22) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
IDLE Fork 0.8 -- press F1 for help
>>> import cgi
>>> cgi.__file__
'C:\\Python22\\lib\\cgi.py'
More information about the Python-list
mailing list