Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #64990

Re: Add directory to sys.path based on variable

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <mail@timgolden.me.uk>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'that?': 0.05; 'sys': 0.07; 'fly': 0.16; 'from:addr:timgolden.me.uk': 0.16; 'from:name:tim golden': 0.16; 'message-id:@timgolden.me.uk': 0.16; 'received:74.55.86': 0.16; 'received:74.55.86.74': 0.16; 'received:smtp.webfaction.com': 0.16; 'received:webfaction.com': 0.16; 'subject:Add': 0.16; 'subject:based': 0.16; 'subject:variable': 0.16; 'sys.path': 0.16; 'tjg': 0.16; 'variable.': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'import': 0.22; 'header:User-Agent:1': 0.23; 'received:192.168.100': 0.24; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'wondering': 0.29; 'fine,': 0.31; 'but': 0.35; 'add': 0.35; 'to:addr:python- list': 0.38; 'to:addr:python.org': 0.39; 'from:addr:mail': 0.83
Date Thu, 30 Jan 2014 12:42:49 +0000
From Tim Golden <mail@timgolden.me.uk>
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.0
MIME-Version 1.0
To python-list@python.org
Subject Re: Add directory to sys.path based on variable
References <08cb4673-c926-487e-a101-299ed899239a@googlegroups.com>
In-Reply-To <08cb4673-c926-487e-a101-299ed899239a@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.6128.1391085772.18130.python-list@python.org> (permalink)
Lines 23
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1391085772 news.xs4all.nl 2841 [2001:888:2000:d::a6]:47167
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:64990

Show key headers only | View raw


On 30/01/2014 12:39, loial wrote:
> I want to add a path to sys.path based upon a variable
> 
> Can I do that?
> 
> Hardcodeing the path works fine, but I want to set it based upon a
> variable.
> 
> I know I can set PYTHONPATH, but just wondering if I can add a
> directory on the fly to sys.path using a variable

Certainly:

<code>
import sys

newpath = "c:/users/tim/modules"
sys.path.append(newpath)

</code>


TJG

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Add directory to sys.path based on variable loial <jldunn2000@gmail.com> - 2014-01-30 04:39 -0800
  Re: Add directory to sys.path based on variable Tim Golden <mail@timgolden.me.uk> - 2014-01-30 12:42 +0000
    Re: Add directory to sys.path based on variable loial <jldunn2000@gmail.com> - 2014-01-30 06:03 -0800
      Re: Add directory to sys.path based on variable Chris Angelico <rosuav@gmail.com> - 2014-01-31 01:09 +1100
      Re: Add directory to sys.path based on variable Tim Golden <mail@timgolden.me.uk> - 2014-01-30 14:14 +0000
        Re: Add directory to sys.path based on variable loial <jldunn2000@gmail.com> - 2014-01-30 06:26 -0800

csiph-web