Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #19396

Re: Distributing methods of a class across multiple files

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 <prvs=364e237b8=jeanmichel@sequans.com>
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 <jeanmichel@sequans.com>
User-Agent Mozilla-Thunderbird 2.0.0.24 (X11/20100328)
MIME-Version 1.0
To lh <lhughes42@gmail.com>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5070.1327492214.27778.python-list@python.org> (permalink)
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

Show key headers only | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Distributing methods of a class across multiple files lh <lhughes42@gmail.com> - 2012-01-24 19:54 -0800
  Re: Distributing methods of a class across multiple files Roy Smith <roy@panix.com> - 2012-01-24 23:05 -0500
  Re: Distributing methods of a class across multiple files Cameron Simpson <cs@zip.com.au> - 2012-01-25 17:15 +1100
  Re: Distributing methods of a class across multiple files "Frank Millman" <frank@chagford.com> - 2012-01-25 10:26 +0200
  Re: Distributing methods of a class across multiple files Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-01-25 11:10 +0000
  Re: Distributing methods of a class across multiple files Jean-Michel Pichavant <jeanmichel@sequans.com> - 2012-01-25 12:49 +0100
    Re: Distributing methods of a class across multiple files lh <lhughes42@gmail.com> - 2012-01-25 07:19 -0800
      Re: Distributing methods of a class across multiple files Neil Cerutti <neilc@norwich.edu> - 2012-01-25 15:42 +0000
      Re: Distributing methods of a class across multiple files Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-01-25 11:53 -0500
        Re: Distributing methods of a class across multiple files Roy Smith <roy@panix.com> - 2012-01-26 09:11 -0500
          Re: Distributing methods of a class across multiple files Chris Angelico <rosuav@gmail.com> - 2012-01-27 01:41 +1100
      Re: Distributing methods of a class across multiple files Chris Angelico <rosuav@gmail.com> - 2012-01-26 20:25 +1100

csiph-web