<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jan 17, 2013 at 9:09 AM, Roy Smith <span dir="ltr"><<a href="mailto:roy@panix.com" target="_blank">roy@panix.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">In article <<a href="mailto:339d9d6d-b000-4cf3-8534-375e0c44b2ca@googlegroups.com">339d9d6d-b000-4cf3-8534-375e0c44b2ca@googlegroups.com</a>>,<br>
<div class="im"> Ferrous Cranus <<a href="mailto:nikos.gr33k@gmail.com">nikos.gr33k@gmail.com</a>> wrote:<br>
<br>
> When trying to open an html template within Python script i use a relative<br>
> path to say go one folder back and open index.html<br>
><br>
> f = open( '../' + page )<br>
><br>
> How to say the same thing in an absolute way by forcing Python to detect<br>
> DocumentRoot by itself?<br>
<br>
</div>Can you give us more details of what you're doing. Is there some web<br>
framework you're using? Can you post some code that's not working for<br>
you?<br>
<span class=""><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></span></blockquote></div><br></div><div class="gmail_extra">Import os<br><br>Then read os.environ['HOME']<br><br></div><div class="gmail_extra">This will give you the home directory of the user. in my case:<br>
<br>>>> os.environ['HOME']<br>'/home/jcg'<br>>>> <br><br></div><div class="gmail_extra">This is probably linux only, but that seems to be the environment you are working in .<br></div><div class="gmail_extra">
<br><br clear="all"></div><div class="gmail_extra"><br>-- <br><div dir="ltr"><div>Joel Goldstick<br></div><a href="http://joelgoldstick.com" target="_blank">http://joelgoldstick.com</a><br></div>
</div></div>