Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!weretis.net!feeder4.news.weretis.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.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.016 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'subject:module': 0.04; 'names.': 0.07; 'script,': 0.07; 'pm,': 0.10; 'wrote:': 0.14; 'defined': 0.14; 'cc:addr:benfinney.id.au': 0.16; 'cc:name:ben finney': 0.16; 'elsewhere,': 0.16; 'risk,': 0.16; 'risks,': 0.16; 'wind': 0.16; 'cc:addr:python-list': 0.17; 'importing': 0.19; 'script.': 0.19; 'yet.': 0.19; 'tree': 0.19; 'header:In-Reply- To:1': 0.21; 'stuff': 0.22; 'cc:no real name:2**0': 0.23; 'module,': 0.23; 'code': 0.24; 'modules': 0.26; 'not.': 0.26; 'pass': 0.27; 'script': 0.27; 'problem': 0.28; 'import': 0.29; 'cc:addr:python.org': 0.30; 'module': 0.30; 'imported': 0.30; 'modules,': 0.30; 'calling': 0.31; 'things': 0.33; "i've": 0.33; 'thinking': 0.34; 'there': 0.35; 'header:User-Agent:1': 0.35; 'module.': 0.35; 'cc:2**1': 0.35; 'certain': 0.36; 'case': 0.37; 'another': 0.37; 'pretty': 0.37; 'two': 0.37; 'run': 0.38; 'eric': 0.38; 'subject:: ': 0.38; 'received:192': 0.38; 'doing': 0.39; 'should': 0.39; 'getting': 0.40; 'really': 0.40; 'received:192.168.1': 0.40; 'watch': 0.60; 'custom': 0.60; 'your': 0.60; 'order': 0.62; 'back': 0.63; 'ways,': 0.67; 'header:Reply- To:1': 0.72; 'reply-to:no real name:2**0': 0.72; '(once': 0.84; '02:59': 0.84; 'snow': 0.91 Date: Wed, 15 Jun 2011 00:02:05 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110516 Thunderbird/3.1.10 MIME-Version: 1.0 To: Eric Snow Subject: Re: break in a module References: <4DF7E75E.9000907@mrabarnett.plus.com> <87k4cnswt9.fsf@benfinney.id.au> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:EQa7GL52qgbvbNu/fScsuSQsiFvC93cP4UUqooi+wfL 2DWn5o2CQnD1W7V46OxA0gtML9n7Rtl0v5C9p0B9lj2Hu7c7g4 Ms/tv2B/amzuI0a+79glI2ujItFr1wNeHZzLetccPnMNwJLR27 YzazFMku23uTYY506f2UrH80F/xO7+102E1bla1Mobpozn/j9D cc2Tfre6COq5+DB3bYnNQ== Cc: python-list@python.org, Ben Finney X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: davea@ieee.org 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: 29 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1308110548 news.xs4all.nl 49181 [::ffff:82.94.164.166]:49476 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:7668 On 01/-10/-28163 02:59 PM, Eric Snow wrote: > > > Unfortunately not. Most of this line of thinking is the result of > looking at import functionality in different ways, including with > regards to the problem of modules getting imported twice (once as > __main__). I've been doing work on multi-file modules, custom module Watch out for that importing of the original script. Doing that has many risks, only one of which is the problem of the two names. In fact, any time you have mutual imports, you run a certain risk, if the modules involved have any code that's not inside defs. It's not well defined what order the initialisation happens, so you may wind up calling code in another module that's not really there yet. The module import tree should be strictly hierarchical, without cycles. if you need stuff from the __main__, pass it to the other module, don't let the other module peek back over your shoulder. In the case of a module importing things from your script, the solution is pretty simple. Move the needed code elsewhere, and import it both from your script and from the other module. DaveA