Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed3.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'read.': 0.03; 'column': 0.07; 'definitions': 0.07; 'problem:': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:question': 0.10; 'python': 0.11; 'finney': 0.16; 'forgiveness': 0.16; 'hierarchy': 0.16; 'implies': 0.16; 'in;': 0.16; 'java.': 0.16; 'navbar': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'task.': 0.16; 'java,': 0.16; 'widget': 0.19; 'putting': 0.22; 'separate': 0.22; 'header:User-Agent:1': 0.23; 'circular': 0.24; 'java': 0.24; 'source': 0.25; 'this:': 0.26; 'header:X-Complaints- To:1': 0.27; 'code': 0.31; 'idea,': 0.31; 'writes:': 0.31; 'class': 0.32; 'sense': 0.34; 'problem': 0.35; 'classes': 0.35; 'but': 0.35; 'there': 0.35; 'instances': 0.36; 'leads': 0.36; 'module.': 0.36; 'received:com.au': 0.36; 'url:org': 0.36; 'should': 0.36; 'ben': 0.38; 'whatever': 0.38; 'to:addr:python- list': 0.38; 'files': 0.38; 'url:2004': 0.39; 'anything': 0.39; 'does': 0.39; 'bad': 0.39; 'url:12': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'most': 0.60; 'tell': 0.60; "you've": 0.63; 'different': 0.65; 'here': 0.66; 'believe': 0.68; 'god,': 0.84; 'nagy': 0.84; 'preached': 0.84; 'received:125': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ben Finney Subject: Re: Import order question Date: Tue, 18 Feb 2014 00:11:34 +1100 References: <53020843.5010804@shopzeus.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: vmx15867.hosting24.com.au X-Public-Key-ID: 0xBD41714B X-Public-Key-Fingerprint: 9CFE 12B0 791A 4267 887F 520C B7AC 2E51 BD41 714B X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-gpg.asc X-Post-From: Ben Finney User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Cancel-Lock: sha1:ejHWbPhXuJNMeeXanal9SzRHqQw= 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: 41 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1392642709 news.xs4all.nl 2865 [2001:888:2000:d::a6]:59168 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:66603 Nagy László Zsolt writes: > I have a class hierarchy like this: > > Widget <- VisualWidget <- BsWidget > > and then BsWidget has many descendants: Desktop, Row, Column, Navbar > etc. None of this implies anything about which modules you place these in; Python is not Java, and you should be putting your class definitions wherever makes the most sense for reading and access. > Here is the problem: these methods should create instances of Row, > Column and Navbar. But this leads to circular imports. It should not; Python is not Java. Use modules to group your class definitions conceptually. There is no need whatever to separate every class into a different module. > * I want to put different widget classes into their corresponding > different source files Please, don't. > This might be a bad idea, but then please tell me why it is bad, and > what would be the right code pattern for this task. Not only does it lead to the problem you've described, it makes the code needlessly difficult to read. Pyth is not Java . -- \ “I do not believe in forgiveness as it is preached by the | `\ church. We do not need the forgiveness of God, but of each | _o__) other and of ourselves.” —Robert G. Ingersoll | Ben Finney