<font color="#000000"><br></font><br><div class="gmail_quote">On Sat, Aug 18, 2012 at 11:19 AM, kj <span dir="ltr"><<a href="mailto:no.email@please.post" target="_blank">no.email@please.post</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Basically, I'm looking for a read-only variable (or variables)<br>
initialized by Python at the start of execution, and from which<br>
the initial working directory may be read or computed.<br></blockquote><div><br></div><div>This will work for Linux and Mac OS X (and maybe Cygwin, but unlikely for native Windows): try the PWD environment variable.</div>
<div><br></div><div><div>>>> import os</div><div>>>> os.getcwd()</div><div>'/Users/swails'</div><div>>>> os.getenv('PWD')</div><div>'/Users/swails'</div><div>>>> os.chdir('..')</div>
<div>>>> os.getcwd()</div><div>'/Users'</div><div>>>> os.getenv('PWD')</div><div>'/Users/swails'</div></div><div><br></div><div>Of course this environment variable can still be messed with, but there isn't much reason to do so generally (if I'm mistaken here, someone please correct me).</div>
<div><br></div><div>Hopefully this is of some help,</div><div>Jason</div></div>