On Mon, Mar 28, 2011 at 6:43 PM, Rance Hall <ran...@gmail.com> wrote:

> I had been doing this under windows:
>
> import os
> import sys
>
> osname = os.name
> pathtocfg = os.path.dirname(sys.argv[0])
> configfileloc = os.path.abspath(pathtocfg)
> os.chdir(configfileloc)
>
> to set the directory of all subsequent file lookups in a script.
>
> It worked underwindows because the shortcuts have a "Start In"
> directory listing.
>
> I need something for Linux use that does not care about a symlink that
> would be used to start the script.
>
> The above code finds the directory the symlink is in.
>
> I'm actually not suprised by this, it is what I expected, I just don't
> understand how to fix it.
>
> How can I do something similar to this, but find the "real" dir?
> Perhaps one of the other sys.argv arguments?
>

print(os.path.realpath(__file__))

HTH,
Wayne
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to