To get the directory of the current running script try:<div><br></div><div>import os.path</div><div>path = os.path.dirname(__file__)</div><div><br><div><br></div><div><br></div>- Gennadiy <<a href="mailto:gennad.zlobin@gmail.com" target="_blank">gennad.zlobin@gmail.com</a>><br>
<br><br><div class="gmail_quote">On Mon, Mar 14, 2011 at 3:25 PM, Alexander Schatten <span dir="ltr"><<a href="mailto:aschatt@gmail.com">aschatt@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi,<br>
<br>
could someone help me with a small problem? I wrote a Python script<br>
that does some RegEx... transformations. Now, this script loads some<br>
configuration data from a file located in the same directory:<br>
<br>
open ('config.txt', 'r').<br>
<br>
However, this only works when I execute the script being in the<br>
directory where the script is locates, because otherwise, of course,<br>
this config file is not found, as the path is relative. Now my<br>
question: is there an easy way (API) to get the directory of the<br>
currently running script? Something along the line of:<br>
<br>
open (API.getCurrentPath + 'config.txt', 'r').<br>
<br>
<br>
thanks a lot,<br>
<br>
cheers<br>
<br>
Alex<br>
<font color="#888888">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></blockquote></div><br></div>