aleaxit at yahoo.com
Fri Sep 8 11:28:43 CEST 2000
"Gilles Lenfant" <glenfant at nospam-e-pack.net> wrote in message
news:8p8l43$piv$1 at reader1.imaginet.fr...
> I'm looking for a simple (and portable) way to get the path of the module
> from within a function it contains.
A module has a __file__ attribute that gives the complete path
to the file from which the module has been loaded. Therefore:
when called from any function (with an import os.path in the
module, of course:-) will give the directory-name from which
the module that contains the function was loaded (this assumes
the function's func_globals have not been tampered with, of
course, but who ever does that?).
More information about the Python-list