How to get full path to script?

Benjamin Kaplan benjamin.kaplan at case.edu
Sun Jun 8 13:14:16 EDT 2008


On Sun, Jun 8, 2008 at 1:03 PM, kj <socyl at 987jk.com.invalid> wrote:

>
>
>
> How can a script know its absolute path?  (__file__ only gives the
> path it was used to invoke the script.)
>
> Basically, I'm looking for the Python equivalent of Perl's FindBin.
>
> The point of all this is to make the scripts location the reference
> point for the location of other files, as part of a self-contained
> distribution.
>
> TIA!
>
> Kynn
>
> --


Anything dealing with file paths is probably going to be in the os.path
module. The function you are looking for is os.path.abspath().

http://docs.python.org/lib/module-os.path.html


>
> NOTE: In my address everything before the first period is backwards;
> and the last period, and everything after it, should be discarded.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080608/3c050a16/attachment-0001.html>


More information about the Python-list mailing list