On Friday, January 18, 2013, Ferrous Cranus wrote: > Τη Πέμπτη, 17 Ιανουαρίου 2013 5:14:19 μ.μ. UTC+2, ο χρήστης Joel Goldstick > έγραψε: > > On Thu, Jan 17, 2013 at 9:09 AM, Roy Smith <r...@panix.com<javascript:;>> > wrote: > > > > In article > > <339d9d6d-b000-4cf3-8534-375e0c44b...@googlegroups.com<javascript:;> > >, > > > > > > > > Ferrous Cranus <nikos...@gmail.com <javascript:;>> wrote: > > > > > > > > > When trying to open an html template within Python script i use a > relative > > > > > path to say go one folder back and open index.html > > > > > > > > > > f = open( '../' + page ) > > > > > > > > > > How to say the same thing in an absolute way by forcing Python to > detect > > > > > DocumentRoot by itself? > >
$ export DOCUMENT_ROOT=${HOME}/public _html Then from python os.environ['DOCUMENT_ROOT'] will have the relative path. I hope this helps. > > > > > > Can you give us more details of what you're doing. Is there some web > > > > framework you're using? Can you post some code that's not working for > > > > you? > > > > -- > > > > http://mail.python.org/mailman/listinfo/python-list > > > > > > > > Import os > > > > Then read os.environ['HOME'] > > > > > > This will give you the home directory of the user. in my case: > > > > > > >>> os.environ['HOME'] > > '/home/jcg' > > >>> > > > > > > This is probably linux only, but that seems to be the environment you > are working in . > > Yes my Python scripts exist in a linux web host. > > os.environ['HOME'] will indeed give the home directory of the user. > > to me /home/nikos/ > > but i want a variable to point to > > /home/nikos/public_html whice is called DocumentRoot. > > is there avariable for that? i can't seem to find any... > -- > http://mail.python.org/mailman/listinfo/python-list >
-- http://mail.python.org/mailman/listinfo/python-list