Retrieve source filename

Shrom shrom at admin.zzn.com
Fri Aug 1 08:49:29 EDT 2003


"Steven Taschuk" <staschuk at telusplanet.net> a écrit dans le message de
news:mailman.1059699303.12610.python-list at python.org...
> Quoth Shrom:
[SNIP]
> 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