__file__
7stud
bbxx789_05ss at yahoo.com
Wed Apr 11 06:03:15 EDT 2007
Hi,
Thanks for the response.
On Apr 11, 12:49 am, "Gabriel Genellina" <gagsl-... at yahoo.com.ar>
wrote:
>
> __file__ corresponds to the filename used to locate and load the module,
> whatever it is. When the module is found on the current directory
> (corresponding to '' in sys.path), you get just the filename; if sys.path
> contains a relative path, that's what you get; the same for any absolute
> path.
> Whatever path worked to find and load the module, that's stored as
> __file__.
>
> If you plan to use it, it's a good idea to make it early into an absolute
> path (using os.path.abspath(__file__)) just in case the current directory
> changes.
>
That last part doesn't seem to fit with your description above. What
does the current working directory have to do with the path that was
used to load a module? I would think the path that was used to load a
module is constant.
More information about the Python-list
mailing list