Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'url:pypi': 0.03; 'level,': 0.07; 'subject:How': 0.09; '3),': 0.09; 'craft': 0.09; 'empty,': 0.09; 'imports': 0.09; 'namespace': 0.09; 'plug': 0.09; 'cc:addr :python-list': 0.10; 'library': 0.15; '__init__.py': 0.16; 'defer': 0.16; 'michael,': 0.16; 'third,': 0.16; 'stefan': 0.17; 'module': 0.19; '(not': 0.20; 'trying': 0.21; 'import': 0.21; 'large,': 0.22; 'libraries': 0.22; 'required.': 0.22; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'creating': 0.26; '[1]': 0.27; '[2]': 0.27; 'initial': 0.28; 'received:192.168.1.3': 0.29; 'toolkit': 0.29; 'usually': 0.30; 'point': 0.31; 'url:python': 0.32; 'url:zope': 0.33; 'another': 0.33; 'direction': 0.35; 'said,': 0.35; 'there': 0.35; 'but': 0.36; 'url:org': 0.36; 'modules': 0.36; 'should': 0.36; 'charset:us-ascii': 0.36; 'well.': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'some': 0.38; 'url:docs': 0.38; 'received:192': 0.39; 'where': 0.40; 'received:192.168': 0.40; 'your': 0.60; 'header:Message-Id:1': 0.62; 'skip:n 10': 0.63; 'other.': 0.64; 'learned': 0.65; 'carefully': 0.71; 'received:at': 0.71; 'cycles.': 0.84; 'subject:improve': 0.84 Subject: Re: How to improve the usability of nested packages Mime-Version: 1.0 (Apple Message framework v1085) Content-Type: text/plain; charset=us-ascii From: "Stefan H. Holek" In-Reply-To: Date: Fri, 2 Nov 2012 19:23:00 +0100 Content-Transfer-Encoding: quoted-printable References: To: Michael Schwarz X-Mailer: Apple Mail (2.1085) Cc: python-list@python.org 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: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1351880590 news.xs4all.nl 6912 [2001:888:2000:d::a6]:36795 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32646 Hi Michael, What we have learned from creating the Zope Toolkit (formerly Zope 3), = is that __init__.py files in namespace packages should be empty, and = imports should be absolute. [1] That said, there are ways to avoid import cycles. One is to very = carefully craft your modules so they do not have to import from each = other. Another is to not have imports at the module level, but move them = into the functions where they are required. Third, large libraries like = the Zope Toolkit usually have mechanisms to defer imports to some point = after initial loading. You may want explore this direction as well. [2] (Not trying to plug the ZTK here, it just happens to be a large, = namespace-using library I know.) Hope this helps, Stefan [1] http://docs.zope.org/zopetoolkit/ [2] http://pypi.python.org/pypi/zope.deferredimport --=20 Stefan H. Holek stefan@epy.co.at