Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #19396
| Date | 2012-01-25 12:49 +0100 |
|---|---|
| From | Jean-Michel Pichavant <jeanmichel@sequans.com> |
| Subject | Re: Distributing methods of a class across multiple files |
| References | <569a94a3-cd84-449b-b0c1-80348014aac6@i10g2000pbl.googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5070.1327492214.27778.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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