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!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'circular': 0.03; 'skip:# 20': 0.03; 'imports': 0.07; 'terry': 0.07; 'scripts': 0.09; 'nameerror:': 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; 'defined': 0.14; 'wrote:': 0.15; 'def.': 0.16; 'executable,': 0.16; 'reedy': 0.16; 'pm,': 0.16; 'question.': 0.16; 'this:': 0.16; 'jan': 0.19; 'header:In-Reply-To:1': 0.22; 'statement': 0.25; 'function': 0.26; 'import': 0.29; 'script': 0.29; 'module': 0.30; 'complete,': 0.30; 'controls': 0.30; 'yes.': 0.30; 'class': 0.31; 'header:User- Agent:1': 0.34; 'header:X-Complaints-To:1': 0.34; 'to:addr:python- list': 0.34; "can't": 0.34; 'running': 0.35; 'but': 0.37; 'received:org': 0.38; 'subject:: ': 0.38; 'header:Mime-Version:1': 0.39; 'data': 0.39; 'to:addr:python.org': 0.39; 'called': 0.40; 'share': 0.68; '"look': 0.84; '11:49': 0.84; 'data?': 0.84; 'done:': 0.84; 'them:': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Project-wide variable... Date: Fri, 24 Jun 2011 02:27:17 -0400 References: <7c6cf5e3-8ba0-45c8-86f8-bf3fc5fa2422@v11g2000prn.googlegroups.com> <2cc8ba29-b669-4f1c-aa42-2e518402917c@p13g2000yqh.googlegroups.com> <4e03f259$0$29975$c3e8da3$5496439d@news.astraweb.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: 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: 35 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1308896848 news.xs4all.nl 14135 [::ffff:82.94.164.166]:37696 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:8350 On 6/23/2011 11:49 PM, Gnarlodious wrote: > Let me restate my question. > Say I have a script Executable.py that calls all other scripts and > controls them: > > #!/usr/local/bin/python > from Module import Data > import ModuleTest > > ModuleTest.py has this: > > print(Data.Plist.Structure) > > Running Executable.py gives me this: > NameError: name 'Data' is not defined > > 1) Can I tell Executable.py to share Data with ModuleTest.py? After the import is complete, yes. import ModuleTest ModuleTest.Data = Data This works if the use of Data is inside a function that is not called during import, not if the use of Data is at toplevel or in a class statement outside a def. > or if that can't be done: > 2) Can I tell ModuleTest.py to "look upstream" for Data? Yes if ModuleTest imports Executable, but circular imports are a bad idea. -- Terry Jan Reedy