Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!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.018 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'algorithms,': 0.07; 'class,': 0.07; 'python': 0.09; 'methods,': 0.09; 'subject:python': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:their': 0.16; 'martin': 0.16; 'wrote:': 0.17; '>>>': 0.18; 'java': 0.21; 'received:209.85.214.174': 0.21; 'class.': 0.23; 'seems': 0.23; 'paul': 0.24; 'header:In-Reply- To:1': 0.25; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'lines': 0.28; 'this?': 0.28; 'writes:': 0.29; 'source': 0.29; 'class': 0.29; 'classes': 0.30; 'fri,': 0.30; 'code': 0.31; 'could': 0.32; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'data,': 0.35; 'nov': 0.35; 'so,': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'really': 0.36; 'but': 0.36; 'alone': 0.36; 'data.': 0.36; 'why': 0.37; 'received:209': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'header:Received:5': 0.40; 'kind': 0.61; 'is.': 0.62; 'needing': 0.62; 'different': 0.63; 'natural': 0.65; 'sounds': 0.71; 'remember,': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=cpa2vXUsppqzFxDcr0gYPxmdjoYI5LRjeZmnUSq0RS0=; b=neSnRuDmTb/Nj4ryum8KER2OaqED0qDv9HA2saW/GCLUKK4nJwh6OWpT+aYd00TY8x WbMszEH2lIZWgoD29pgCNMqqr/6yYyMeOBoBp/FOo9u2jUM6hsWB0WLejS2hMI9DPhDl Ug0JmwTx3CTZYJ12hYoqD4xbHZ5bULqCWlxAB/vTYXuCII5WGAjVGM3I6HPI4jvvhCyH sX3WnIOo6Eyn+i0KIPt90itdnqKR8E+JiFqcwsbXGcEdp+0hNLT3RatN6RvVnOfctbDb IsgphuvH/+BjCJ2qCTospLBKScPwVakaGW6cWMAdmuJKrNp/ck+w7z0ycjtaouC+JtH8 RByg== MIME-Version: 1.0 In-Reply-To: References: <7xa9v0wj2g.fsf@ruckus.brouhaha.com> Date: Fri, 2 Nov 2012 20:15:11 +1100 Subject: Re: Organisation of python classes and their methods From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: 1351847720 news.xs4all.nl 6946 [2001:888:2000:d::a6]:52314 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32607 On Fri, Nov 2, 2012 at 7:08 PM, Martin Hewitson wr= ote: > > On 2, Nov, 2012, at 08:38 AM, Paul Rubin wrote: > >> Martin Hewitson writes: >>> So, is there a way to put these methods in their own files and have >>> them 'included' in the class somehow? ... 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. >> >> That code sounds kind of smelly... why are there so many methods per >> class? > > Simply because there are many different ways to process the data. The cla= ss encapsulates the data, and the user can process the data in many ways. O= f course, one could have classes which encapsulate the algorithms, as well = as the data, but it also seems natural to me to have algorithms as methods = which are part of the data class, so the user operates on the data using me= thods of that class. Are these really needing to be methods, or ought they to be module-level functions? Remember, Python code doesn't have to be organized into classes the way Java code is. ChrisA