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


Groups > comp.lang.python > #41391

How to add the current dir to sys.path when calling a python file?

Path csiph.com!usenet.pasdenom.info!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 <pengyu.ut@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'argument': 0.04; 'so?': 0.07; 'subject:file': 0.07; 'subject:How': 0.09; 'python': 0.09; '"if': 0.09; 'given,': 0.09; 'inserted': 0.09; 'subject:python': 0.11; 'subject:when': 0.16; 'script.': 0.17; 'variable': 0.20; 'script': 0.24; 'message-id:@mail.gmail.com': 0.27; 'says': 0.33; 'to:addr:python-list': 0.33; 'front': 0.33; 'hi,': 0.33; 'received:google.com': 0.34; 'path': 0.35; 'subject:?': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'anything': 0.36; 'received:209': 0.37; 'instead': 0.39; 'to:addr:python.org': 0.39; 'containing': 0.61; 'within': 0.64; 'subject:add': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=MWyg99fr3PFNdl/FzYCmOSQZWxmCdyJInTcYtlBHfTI=; b=MVercQ+Pw8X1uO+EIOXKolQ1NrI5iRMGkmo5U9L13Df4WGJa6AFbLErlFoWnXXAtix rUPQfxr88bxhuvZhjq/7A4Mu6B0WLLXO24lhWycAD5NL5ZNArRzoWy3bj/xF9RO2nPgo bC6JkTKwpO9ZDOtaO5bNPjK6we0OeZscg++yJjQ0A7H8Fe2y2vaw1iaoLdGxrBs7P92Z xBM9TqyF1BhAl55+13a70CNAMc+k+wjEHnac1yDuY/ilJHIqNQLUVRacT6FHqLDlBOyi sEwDrdqRmYjLJpBKTEWJ8qL0TgZ3pS8ATTDm1+WV/c7h3uzi0KeABj1O66QcY1dWHnhP qVTg==
MIME-Version 1.0
X-Received by 10.49.108.104 with SMTP id hj8mr20326601qeb.4.1363578967719; Sun, 17 Mar 2013 20:56:07 -0700 (PDT)
Date Sun, 17 Mar 2013 22:56:07 -0500
Subject How to add the current dir to sys.path when calling a python file?
From Peng Yu <pengyu.ut@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
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 <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3407.1363579363.2939.python-list@python.org> (permalink)
Lines 12
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1363579363 news.xs4all.nl 6936 [2001:888:2000:d::a6]:45103
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:41391

Show key headers only | View raw


Hi,

man python says "If a script  argument  is  given,  the directory
containing the script is inserted in the path in front of $PYTHONPATH.
The search path can be manipulated from  within a Python program as
the variable sys.path." Instead I want to have the current directory
inserted to the front of $PYTHONPATH without changing anything the
script. Is there a way to do so?

-- 
Regards,
Peng

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


Thread

How to add the current dir to sys.path when calling a python file? Peng Yu <pengyu.ut@gmail.com> - 2013-03-17 22:56 -0500
  Re: How to add the current dir to sys.path when calling a python file? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-18 06:54 +0000
    Re: How to add the current dir to sys.path when calling a python file? Peng Yu <pengyu.ut@gmail.com> - 2013-03-18 08:52 -0500
  Re: How to add the current dir to sys.path when calling a python file? rusi <rustompmody@gmail.com> - 2013-03-18 00:35 -0700

csiph-web