path to python file given module
Gene
genezhang at gmail.com
Sun Jan 9 19:46:11 EST 2005
that method doesn't seem to work as well on UNIX:
wla apocalypse[94] ~/filegen > ls
filegen.py OLDwla_csv2objects.py wlaclasses.py
filegen.pyc templates/ wlaclasses.pyc
gen_all_from_csv.py test.py*
wla apocalypse[95] ~/filegen > python
...
>>> import filegen, inspect
>>> inspect.getsourcefile(filegen)
'filegen.py'
>>> inspect.getsourcefile(filegen.Lecture)
'wlaclasses.py'
>>> import os
>>> os.chdir('..')
>>> inspect.getsourcefile(filegen)
>>> print inspect.getsourcefile(filegen)
None
>>> print inspect.getsourcefile(filegen.Lecture)
None
More information about the Python-list
mailing list