Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'subject:Python': 0.05; 'only,': 0.07; 'python': 0.09; 'forcing': 0.09; 'cc:addr:python- list': 0.10; 'template': 0.11; 'index.html': 0.16; 'roy': 0.16; 'wrote:': 0.17; 'detect': 0.17; 'thu,': 0.17; 'jan': 0.18; '>>>': 0.18; 'email addr:gmail.com>': 0.20; 'trying': 0.21; 'import': 0.21; '>>>': 0.22; 'cc:2**0': 0.23; '>': 0.23; 'absolute': 0.23; 'user.': 0.23; 'seems': 0.23; 'linux': 0.24; 'script': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'am,': 0.27; 'skip:& 60': 0.27; 'message- id:@mail.gmail.com': 0.27; 'post': 0.28; 'environment': 0.29; 'url:mailman': 0.29; 'probably': 0.29; 'folder': 0.30; 'framework': 0.30; 'relative': 0.30; 'code': 0.31; 'you?': 0.32; 'url:python': 0.32; 'url:listinfo': 0.32; 'received:google.com': 0.34; 'path': 0.35; 'open': 0.35; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; 'url:org': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'page': 0.38; 'url:mail': 0.40; 'back': 0.62; 'details': 0.63; 'more': 0.63; 'within': 0.64; 'home': 0.66; 'smith': 0.71; 'article': 0.78; '2013': 0.84; 'itself?': 0.84; 'joel': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=Mj4fLxb1TYkpxkvdKJlvnT7cecrilfwV6cyTg2xvHeg=; b=U6qK04YHqpG9cJ7ZXx6haCtFUfEnU9atXkMUWpuCB4+YGN0uPA2dxU1UB99IUXmBPM PVkJ5Ky+IIZGGtGFepjKuJ9fDtbOkvaJal1kIi6h/HUed/Ademy8rlKym39/1jXLhWDM xNEBWmaotP5glmzhtajYTaB4/RRoUNqVnFVItIsB7TEVle0SnTeK7s2zf6x740TY+Epy VlUvzEon69sRWcgnHTI4+fbL1pE+I5mkUP/LXmn8yAzPQIWRjtkj83A3JeutOYPHejei 4Qz3U+15MnL12RbULqysvAE17WKxDjtnqJKwc2RjgFt9R3qD8siuHFzDvxi5RJpRP3Y1 5Dpg== MIME-Version: 1.0 X-Received: by 10.52.19.172 with SMTP id g12mr5016888vde.14.1358435659275; Thu, 17 Jan 2013 07:14:19 -0800 (PST) In-Reply-To: References: <339d9d6d-b000-4cf3-8534-375e0c44b2ca@googlegroups.com> Date: Thu, 17 Jan 2013 10:14:19 -0500 Subject: Re: Forcing Python to detect DocumentRoot From: Joel Goldstick To: Roy Smith Content-Type: multipart/alternative; boundary=20cf307c9d96ebdcb904d37d72eb Cc: "python-list@python.org" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 91 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1358435662 news.xs4all.nl 6901 [2001:888:2000:d::a6]:42196 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:36942 --20cf307c9d96ebdcb904d37d72eb Content-Type: text/plain; charset=UTF-8 On Thu, Jan 17, 2013 at 9:09 AM, Roy Smith wrote: > In article <339d9d6d-b000-4cf3-8534-375e0c44b2ca@googlegroups.com>, > Ferrous Cranus 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? > > 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 . -- Joel Goldstick http://joelgoldstick.com --20cf307c9d96ebdcb904d37d72eb Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable



On Thu, Jan 17, 2013 at 9:09 AM, Roy Smith <roy@panix.com> wrote:
In article <339d9d6d-b00= 0-4cf3-8534-375e0c44b2ca@googlegroups.com>,
=C2=A0Ferrous Cranus <nikos.gr33k@gmail.com> wrote:

> When trying to open an html template within Python script i use a rela= tive
> path to say go one folder back and open index.html
>
> f =3D open( '../' + page )
>
> How to say the same thing in an absolute way by forcing Python to dete= ct
> DocumentRoot by itself?

Can you give us more details of what you're doing. =C2=A0Is there= some web
framework you're using? =C2=A0Can you post some code that's not wor= king for
you?
--
http://mail.python.org/mailman/listinfo/python-list

Impor= t os

Then read os.environ['HOME']

This will give you the home directory of the user.=C2=A0 in m= y case:

>>> os.environ['HOME']
'/home/jcg'
>&= gt;>

This is probably linux onl= y, but that seems to be the environment you are working in .



--
--20cf307c9d96ebdcb904d37d72eb--