Retrieve source filename

Bernhard Herzog bh at intevation.de
Fri Aug 1 09:03:53 EDT 2003


Steven Taschuk <staschuk at telusplanet.net> writes:

> As of 2.3, the __main__ module also has a __file__ attribute, so
> you can just do
>     sys.modules[__name__].__file__

Why so complicated? Just as __name__, __file__ is simply a global
variable in the module, so you can use it directly.

   Bernhard

-- 
Intevation GmbH                                 http://intevation.de/
Sketch                                 http://sketch.sourceforge.net/
Thuban                                  http://thuban.intevation.org/




More information about the Python-list mailing list