Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.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; 'explicitly': 0.04; '(using': 0.07; '*not*': 0.07; 'attributes': 0.07; 'executable': 0.07; 'responding': 0.07; 'suggestions,': 0.07; 'python': 0.09; 'callback': 0.09; 'currently,': 0.09; 'facts': 0.09; 'imports': 0.09; 'linux.': 0.09; 'modules.': 0.09; 'script,': 0.09; 'subject:module': 0.09; 'subtle': 0.09; 'stored': 0.10; 'gui': 0.11; 'suggest': 0.11; 'yet.': 0.13; '(like': 0.15; '"module"': 0.16; 'above)': 0.16; 'commandline': 0.16; 'encountered,': 0.16; 'execute,': 0.16; 'guessing': 0.16; 'hierarchy': 0.16; 'mistake.': 0.16; 'modules,': 0.16; 'replaces': 0.16; 'sorts': 0.16; 'subject:accessing': 0.16; 'subject:created': 0.16; 'wrote:': 0.17; 'circular': 0.17; 'module,': 0.17; 'script.': 0.17; 'code,': 0.18; 'module': 0.19; 'define': 0.20; 'suggested': 0.20; 'trying': 0.21; 'import': 0.21; 'runs': 0.22; 'example': 0.23; 'purposes': 0.23; 'statement': 0.23; 'random': 0.24; 'script': 0.24; 'least': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'guess': 0.27; 'mix': 0.27; 'tree': 0.27; 'environment': 0.29; 'words': 0.29; 'class': 0.29; "i'm": 0.29; 'that.': 0.30; 'function': 0.30; 'stuff': 0.30; 'sense': 0.31; 'code': 0.31; 'generally': 0.32; 'launch': 0.32; 'running': 0.32; 'could': 0.32; 'defining': 0.33; 'instances': 0.33; 'strict': 0.33; 'to:addr:python-list': 0.33; 'typically': 0.33; 'another': 0.33; "can't": 0.34; 'whatever': 0.35; 'ahead': 0.35; 'problem,': 0.35; 'really': 0.36; 'but': 0.36; 'child': 0.36; 'data.': 0.36; 'problems': 0.36; 'possible': 0.37; 'two': 0.37; 'detail': 0.37; 'rather': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'end': 0.40; 'think': 0.40; 'your': 0.60; "you'll": 0.62; 'different': 0.63; 'more': 0.63; 'hesitate': 0.66; 'received:74.208': 0.71; 'home.': 0.76; 'clearer': 0.84; 'coherent': 0.84; 'confusing': 0.84; 'implications': 0.84; 'intending': 0.84; "it'd": 0.84; 'launch,': 0.84; 'points,': 0.84; 'eliminates': 0.93; 'processes,': 0.93 Date: Sat, 09 Mar 2013 07:02:28 -0500 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130221 Thunderbird/17.0.3 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Running external module and accessing the created objects References: <513aecd3$0$6512$c3e8da3$5496439d@news.astraweb.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:XUYPsldmTyLczMpBDl3BW0qaTFMHKLdZEuOjxr8gs+7 hN+PpZ/iuV7mNl8a5vwZKkRVjTMCPSYKuVibxHN9FwT9lrBVIp 9OPr98DH+5Pkc62u4wfEdi0tO3pkRvilMMU6hCvRtjXpdlz3Dh L97CUPfpEZoh8BwWMCcvtyXmTSkClJIqXH4IBC5DQbriq66pug qx6fVGJi9EUX46nlOWHNDIFe3We9y8AtXIJTpxsHWxULyBOBb9 1F0PNYmXx9evFuSJf7ix7ffZKXeikhTuttEDnykil+DnoEMeZI WBLnw2fQbxPcZkSvbAKXfsPvYYOr3exHoICdS5doQSZcJ69KQ= = 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: 62 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1362830573 news.xs4all.nl 6942 [2001:888:2000:d::a6]:51983 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:40944 On 03/09/2013 06:05 AM, Kene Meniru wrote: > > (lots of stuff that was more confusing to me than helpful) You use the words launch, encountered, execute, and others in ways that do not make sense to me, or are at least ambiguous. You have an explicitly named user.py, which apparently is *not* generally named that. I could give you lots of random facts and suggestions, and one of the might hit home. For example the __import__() function can import a module that you don't know the name of ahead of time. It's not often the right answer, though, so I hesitate to suggest it. For another example, if you import a module by two different names, or if you import the "module" that is your starting script, then you can end up with two instances of such a module, with all sorts of negative implications about global data or class attributes stored in that module, or even more subtle problems. For a final example, having a circular import tree can cause problems if any of those imports have any global code (like class initialization, defining constants, etc.). It's generally much better to define a strict hierarchy of who imports whom. But I think instead that it'd be better for you to make a clearer statement about how your code is structured. I'm guessing that all of this is intended to be in one executable -- no child processes, etc. So don't say launch, say import, or function-call, or whatever you are really doing. I'm guessing that you're running this on Python 3.3 under Linux. I'm guessing that "user.py" is one possible name that a particular user calls his script. And that script is what he runs on the Python commandline. python user.py And that script calls functions in app.py, doc.py, and/or appwin.py. And that currently, you're trying to import user.py from one of your own modules, for purposes of either callback functions or global data access. That's a mistake. When you import your *script* (using __import__() as suggested above) you get a new copy of the script, and new copies of all its global data. I can't even guess how you're intending to mix the commandline stuff of app.py with gui stuff in one or more appwin.py variants. You'll have to be explicit, if it even matters yet. I suggest that rather than responding to these points, you restate your problem, in one place, with coherent detail that eliminates these guesses and replaces them with reality. Start with the environment this is running in, and the commandline typically used to launch the code, and the interdepencies of the various modules. -- DaveA