Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.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.012 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'imported': 0.09; 'subject:modules': 0.09; 'def': 0.10; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; "module's": 0.16; 'namespace.': 0.16; 'subject:class': 0.16; 'subject:instance': 0.16; 'wrote:': 0.17; 'module,': 0.17; 'module': 0.19; 'import': 0.21; 'example': 0.23; 'demonstrate': 0.23; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'function': 0.30; 'could': 0.32; 'print': 0.32; 'to:addr:python-list': 0.33; 'skip:- 20': 0.34; 'pm,': 0.35; 'subject:?': 0.35; 'received:org': 0.36; 'michael': 0.36; 'but': 0.36; 'message-id:@gmail.com': 0.36; 'subject:: ': 0.38; 'there,': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'header:Received:5': 0.40; 'your': 0.60; 'wrong!': 0.84 X-Virus-Scanned: amavisd-new at torriefamily.org Date: Wed, 06 Feb 2013 17:14:27 -0700 From: Michael Torrie User-Agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.12) Gecko/20130105 Thunderbird/10.0.12 MIME-Version: 1.0 To: python-list@python.org Subject: Re: best way to share an instance of a class among modules? References: <15fe7153-a77a-49eb-9cf8-d4e59b4a2079@z9g2000vbx.googlegroups.com> <5db4add7-ab9c-4311-b3b6-24156cd6f248@z4g2000vbz.googlegroups.com> <5112EF48.6040404@gmail.com> In-Reply-To: <5112EF48.6040404@gmail.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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1360196074 news.xs4all.nl 6851 [2001:888:2000:d::a6]:57786 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:38319 On 02/06/2013 05:03 PM, Michael Torrie wrote: > Every function in a module has access to the module's global namespace. > And your shared_cursor is there, inside of the utilities reference, > since utilities was imported into your module, "importer." Just to be clear: mod1.py: a=5 ------------------------ mod2.py: import mod1 def testfunc1(): print mod1.a def testfunc2(): mod1.a = 6 ------------------------- main.py: import mod1 import mod2 mod2.testfunc1() mod2.testfunc2() mod2.testfunc1() ----------------------- The main.py program will print out "5" and "6." If I understand your original question, this example will demonstrate it. But I could have understood wrong!