How to retrieve the filename of a module

Lawrence Oluyede raims at dot.com
Thu Oct 20 12:27:22 EDT 2005


Il 2005-10-20, mku <martin.kuner at thomson.net> ha scritto:
> Hi,
>
> thereŽs a function inside a module. How can these function retrieve
> the path+name   of his module ? (The path is most important).
> That should also work if the module is part of a package.


rhymes at voodoo:~ $ cat > test.py
print __file__
import os
print os.path.abspath(__file__)

rhymes at voodoo:~ $ python test.py
test.py
/home/rhymes/test.py

Bye



-- 
Lawrence
http://www.oluyede.org/blog



More information about the Python-list mailing list