Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1a.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'attribute': 0.07; 'level,': 0.07; 'postpone': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'references.': 0.09; 'python': 0.11; 'wrote': 0.14; 'imports': 0.16; 'modules.': 0.16; 'received:80.91.229.3': 0.16; 'received:97': 0.16; 'received:plane.gmane.org': 0.16; 'smith"': 0.16; 'subject:caught': 0.16; 'subject:import': 0.16; 'module': 0.19; 'import': 0.22; 'putting': 0.22; 'references': 0.26; 'gets': 0.27; 'header:X-Complaints-To:1': 0.27; 'function': 0.29; 'evaluation': 0.30; 'code': 0.31; 'class': 0.32; 'guess': 0.33; 'subject:the': 0.34; 'there': 0.35; "i'll": 0.36; 'similar': 0.36; 'level': 0.37; 'depends': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'called': 0.40; 'tips': 0.61; 'such': 0.63; 'forward': 0.65; '(that': 0.65; 'hoping': 0.75; 'delaying': 0.84; 'good,': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dave Angel Subject: Re: caught in the import web again Date: Mon, 17 Nov 2014 17:17:07 -0500 (EST) Organization: news.gmane.org References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 97.73.240.63 X-Newsreader: PiaoHong.Usenet.Client.VIP:1.65 X-Archive: encrypt 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: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1416262622 news.xs4all.nl 2912 [2001:888:2000:d::a6]:57671 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:80984 "Charles T. Smith" Wrote in message: > Well, I guess that's the definitive answer... the tips for delaying > import are good, I'll try to leverage them. > > I was hoping there would be a way to have python postpone evaluation > similar to C's forward references. > In a module that might get tangled in a cycle, avoid global code that depends on other modules. Instead of putting such initialization at top level, put inside a function that gets called after all suspect imports are completed. (That function has global keywords ). Similarly avoid class attribute initialization at class level, if such initialization references higher level modules. -- DaveA