Path: csiph.com!usenet.pasdenom.info!news.albasani.net!feeder.erje.net!eu.feeder.erje.net!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'class,': 0.07; 'classes.': 0.07; 'cure': 0.07; 'problem?': 0.07; 'python': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'looked': 0.10; 'subject:python': 0.11; 'file,': 0.15; 'googled': 0.16; 'received:80.91.229.3': 0.16; 'received:dip.t-dialin.net': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-dialin.net': 0.16; 'subject:their': 0.16; 'martin': 0.16; 'wrote:': 0.17; 'module': 0.19; 'code.': 0.20; "i'd": 0.22; "haven't": 0.23; 'header:User- Agent:1': 0.26; "doesn't": 0.28; 'header:X-Complaints-To:1': 0.28; 'lines': 0.28; 'this?': 0.28; 'trouble': 0.28; 'long.': 0.29; 'piece': 0.29; 'source': 0.29; 'class': 0.29; "i'm": 0.29; 'classes': 0.30; 'usually': 0.30; 'sense': 0.31; 'code': 0.31; 'file': 0.32; 'google,': 0.32; 'operate': 0.32; 'belong': 0.33; 'instances': 0.33; 'to:addr:python-list': 0.33; 'project': 0.34; 'clear': 0.35; 'so,': 0.35; 'there': 0.35; 'received:org': 0.36; 'really': 0.36; 'but': 0.36; 'alone': 0.36; 'modules': 0.36; "didn't": 0.36; 'method': 0.36; 'editor': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'to:addr:python.org': 0.39; 'list,': 0.39; 'little': 0.39; 'header:Received:5': 0.40; 'bring': 0.62; 'relatively': 0.62; 'organisation': 0.65; 'dear': 0.66; 'analysis': 0.70; 'seriously,': 0.91; 'many,': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Peter Otten <__peter__@web.de> Subject: Re: Organisation of python classes and their methods Date: Fri, 02 Nov 2012 09:00:39 +0100 Organization: None References: Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Gmane-NNTP-Posting-Host: p50849249.dip.t-dialin.net User-Agent: KNode/4.7.3 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: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1351843247 news.xs4all.nl 6922 [2001:888:2000:d::a6]:46479 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32596 Martin Hewitson wrote: > Dear list, > > I'm relatively new to Python and have googled and googled but haven't > found a reasonable answer to this question, so I thought I'd ask it here. > > I'm beginning a large Python project which contains many packages, modules > and classes. The organisation of those is clear to me. > > Now, the classes can contain many methods (100s of data analysis methods) > which operate on instances of the class they belong to. These methods can > be long and complex. So if I put these methods all in the module file > inside the class, the file will get insanely long. Reading on google, the > answer is usually "refactor", but that really doesn't make sense here. > It's just that the methods are many, and each method can be a long piece > of code. So, is there a way to put these methods in their own files and > have them 'included' in the class somehow? I read a little about mixins > but all the solutions looked very hacky. Is there an official python way > to do this? I don't like having source files with 100's of lines of code > in, let alone 1000's. You googled, found the right answer ("refactor"), didn't like it and are now looking to cure the symptoms of the original problem? Seriously, a good editor can deal with a long source file, but a class with hundreds of methods will bring trouble to any old brain.