<div class="gmail_quote">On Mon, Mar 28, 2011 at 6:43 PM, Rance Hall <span dir="ltr">&lt;<a href="mailto:ranceh@gmail.com">ranceh@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

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