Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.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.016 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'class,': 0.07; 'classes.': 0.07; 'python': 0.09; 'looked': 0.10; 'subject:python': 0.11; 'googled': 0.16; 'received:mac.com': 0.16; 'subject:their': 0.16; 'martin': 0.16; 'thanks,': 0.18; 'module': 0.19; 'code.': 0.20; "i'd": 0.22; 'cc:2**0': 0.23; "haven't": 0.23; "doesn't": 0.28; 'lines': 0.28; 'this?': 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; 'received:17': 0.35; 'so,': 0.35; 'received:192.168.0': 0.35; 'there': 0.35; 'really': 0.36; 'but': 0.36; 'alone': 0.36; 'modules': 0.36; 'method': 0.36; 'charset:us-ascii': 0.36; 'data': 0.37; 'files': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'list,': 0.39; 'little': 0.39; 'received:192.168': 0.40; 'relatively': 0.62; 'organisation': 0.65; 'dear': 0.66; 'analysis': 0.70; 'many,': 0.93 MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.7.7855,1.0.431,0.0.0000 definitions=2012-11-02_01:2012-11-01, 2012-11-02, 1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 ipscore=0 suspectscore=1 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=6.0.2-1203120001 definitions=main-1211010401 From: Martin Hewitson Subject: Organisation of python classes and their methods Date: Fri, 02 Nov 2012 07:16:09 +0100 To: python-list@python.org X-Mailer: Apple Mail (2.1499) 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: 12 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1351840590 news.xs4all.nl 6894 [2001:888:2000:d::a6]:34941 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32593 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. Many thanks, Martin