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


Groups > comp.lang.python > #51568

Re: importing modules

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
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; 'scripts': 0.03; 'pointers': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'scripts,': 0.09; 'subject:modules': 0.09; 'variable,': 0.09; 'sfxlen:2': 0.11; 'python': 0.11; 'modules,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'script,': 0.16; 'sys.path': 0.16; 'wrote:': 0.18; 'file,': 0.19; 'import': 0.22; 'cc:addr:python.org': 0.22; 'header:User-Agent:1': 0.23; 'directory.': 0.24; 'environment': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'another': 0.32; 'but': 0.35; 'add': 0.35; 'there': 0.35; 'ubuntu': 0.36; 'words,': 0.36; 'done': 0.36; 'doing': 0.36; 'list': 0.37; 'to:addr:python-list': 0.38; 'list,': 0.38; 'pm,': 0.38; 'short': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'you.': 0.62; 'provide': 0.64; 'located.': 0.84; 'syed': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dave Angel <davea@davea.name>
Subject Re: importing modules
Date Tue, 30 Jul 2013 11:37:48 -0400
References <CAHc+NX2j9Y0ipgw5vV8_i7cguhYWjh0MH-+CDM4a-SXJqhB6LQ@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host wsip-68-106-144-188.dc.dc.cox.net
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130623 Thunderbird/17.0.7
In-Reply-To <CAHc+NX2j9Y0ipgw5vV8_i7cguhYWjh0MH-+CDM4a-SXJqhB6LQ@mail.gmail.com>
Cc python-dev@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 <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.5314.1375198689.3114.python-list@python.org> (permalink)
Lines 19
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1375198689 news.xs4all.nl 15996 [2001:888:2000:d::a6]:43519
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:51568

Show key headers only | View raw


On 07/29/2013 05:57 PM, syed khalid wrote:
> I am attempting to import modules from Shogun to python from a non-standard
> python directory ie from my /home/xxx directory. is there a way on ubuntu
> to selectively some modules, scripts, data  from one directory and others
> modules, scripts from another directory. In other words, is there a file(s)
> that provide pointers to where these modules are located.
>

Your question is confusing, but the short answer is that import will 
search the sys.path list for you.  So in your main script, you can add a 
directory to that list,  before doing the imports.

It can also be done with an environment variable, or with the site file, 
but I don't bother.


-- 
DaveA

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


Thread

Re: importing modules Dave Angel <davea@davea.name> - 2013-07-30 11:37 -0400

csiph-web