Retrieve source filename
Irmen de Jong
irmen at -NOSPAM-REMOVETHIS-xs4all.nl
Thu Jul 31 13:33:15 EDT 2003
Shrom wrote:
> I know that you can retrieve main file name with sys.argv[0] and file name
> for a module with modulename.__file__ but is there a common way to retrieve
> file name for both main program and modules as the __FILE__ constant in PHP
> ?
I don't know if it's the "right" way, but this works:
import inspect
print inspect.getfile(inspect.currentframe())
--Irmen
More information about the Python-list
mailing list