Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'terry': 0.07; "'''": 0.09; '>>>>': 0.09; '__name__': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'am,': 0.13; 'wrote:': 0.15; "'__main__':": 0.16; 'reedy': 0.16; 'test_main()': 0.16; 'test_main():': 0.16; 'def': 0.16; 'jan': 0.19; 'seems': 0.20; 'variable': 0.21; 'header:In-Reply-To:1': 0.22; 'hall': 0.26; 'load': 0.26; "i'm": 0.27; 'mine': 0.28; 'import': 0.29; 'parent': 0.30; 'yes.': 0.30; "skip:' 10": 0.32; 'header:User-Agent:1': 0.34; 'header:X-Complaints-To:1': 0.34; 'to:addr:python-list': 0.34; 'test': 0.34; 'project': 0.35; 'file': 0.36; 'doing': 0.37; 'could': 0.38; 'received:org': 0.38; 'something': 0.38; 'subject:: ': 0.38; 'common': 0.39; 'header:Mime-Version:1': 0.39; 'data': 0.39; 'to:addr:python.org': 0.39; 'missing': 0.40; 'copyright': 0.63; 'jun': 0.67; 'wish': 0.70 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Project-wide variable... Date: Thu, 23 Jun 2011 14:10:55 -0400 References: <7c6cf5e3-8ba0-45c8-86f8-bf3fc5fa2422@v11g2000prn.googlegroups.com> <2cc8ba29-b669-4f1c-aa42-2e518402917c@p13g2000yqh.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: rain.gmane.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.18) Gecko/20110616 Lightning/1.0b2 Thunderbird/3.1.11 In-Reply-To: <2cc8ba29-b669-4f1c-aa42-2e518402917c@p13g2000yqh.googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 31 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1308852668 news.xs4all.nl 14133 [::ffff:82.94.164.166]:33933 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:8321 On 6/23/2011 10:09 AM, Gnarlodious wrote: > On Jun 23, 7:59 am, Noah Hall wrote: >>>> >from a import x > > I'm doing that: > import Module.Data as Data > > However I end up doing it in every submodule, so it seems a little > redundant. I wish I could load the variable in the parent program and > have it be available in all submodules. Am I missing something? Yes. Make a project ~template.py file that includes the common import. Mine is something like #!python3 '''project_dir/.py -- 2011 Copyright Terry Jan Reedy ''' from test import ftest,itest def test_main(): if __name__ == '__main__': test_main() -- Terry Jan Reedy