Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'example:': 0.03; 'names.': 0.07; 'cents': 0.09; 'foo': 0.09; 'subject:files': 0.09; 'cc:addr :python-list': 0.15; 'question.': 0.15; '(normally': 0.16; 'indent': 0.16; 'narrow': 0.16; 'scopes': 0.16; 'textually': 0.16; 'wrote:': 0.16; 'please?': 0.18; 'long,': 0.19; 'cc:no real name:2**0': 0.21; 'file,': 0.21; "doesn't": 0.22; 'header:In- Reply-To:1': 0.22; 'obviously': 0.23; 'long.': 0.23; 'defined': 0.24; 'cc:2**0': 0.25; 'code': 0.25; 'import': 0.27; 'cc:addr:python.org': 0.29; 'class': 0.29; "isn't": 0.32; 'done': 0.33; 'header:User-Agent:1': 0.33; 'searches': 0.34; 'thank': 0.35; 'file': 0.35; 'google': 0.36; 'but': 0.37; 'spread': 0.37; 'could': 0.37; 'some': 0.38; 'define': 0.39; 'files': 0.39; 'subject:: ': 0.39; 'under': 0.40; 'your': 0.61; 'ridiculously': 0.84 X-IronPort-AV: E=Sophos;i="4.71,567,1320620400"; d="scan'208";a="101807" X-Virus-Scanned: amavisd-new at zimbra.sequans.com Date: Wed, 25 Jan 2012 12:49:37 +0100 From: Jean-Michel Pichavant User-Agent: Mozilla-Thunderbird 2.0.0.24 (X11/20100328) MIME-Version: 1.0 To: lh Subject: Re: Distributing methods of a class across multiple files References: <569a94a3-cd84-449b-b0c1-80348014aac6@i10g2000pbl.googlegroups.com> In-Reply-To: <569a94a3-cd84-449b-b0c1-80348014aac6@i10g2000pbl.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 1327492214 news.xs4all.nl 6936 [2001:888:2000:d::a6]:59130 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:19396 lh wrote: > Is this possible please? I have done some searching but it is hard to > narrow down Google searches to this question. What I would like to do > is, for example: > 1) define a class Foo in file test.py... give it some methods > 2) define a file test2.py which contains a set of methods that are > methods of class Foo defined in test.py. I can import Foo obviously > but it isn't clear to me how to identify the methods in test2.py to be > methods of class Foo defined in test.py (normally I would just indent > them "def"'s under the class but the class isn't textually in > test2.py). > > In short I would like to distribute code for one class across multiple > files so a given file doesn't get ridiculously long. > > Thank you, > Luke > If the file is ridiculously long, could be that the class has a ridiculous number of methods. If you spread your class into multiple files, you will have a ridiculous number of tiny files with ridiculous names. My 2 cents : keep 1 class in 1 file, and keep your scopes consistent. JM