Retrieve source filename

Shrom shrom at
Fri Aug 1 14:49:29 CEST 2003

"Steven Taschuk" <staschuk at> a écrit dans le message de
news:mailman.1059699303.12610.python-list at
> Quoth Shrom:
> As of 2.3, the __main__ module also has a __file__ attribute, so
> you can just do
>     sys.modules[__name__].__file__
> The (an?) exception is when __main__ is the text in a 'python -c'
> command -- then there is, of course, no file name.  And for
> compatibility with versions < 2.3, you have to check for the case
> __name__ == '__main__' and go to sys.argv[0].

Thanks very much that's what i was searching.

More information about the Python-list mailing list