[Python-Dev] On breaking modules into packages Was: [issue10199] Move Demo/turtle under Lib/

R. David Murray rdmurray at bitdance.com
Wed Oct 27 05:35:33 CEST 2010


On Tue, 26 Oct 2010 16:46:15 -0400, Michael Foord wrote:
> On 26/10/2010 15:05, R. David Murray wrote:
> > On Tue, 26 Oct 2010 10:39:19 -0700, Raymond Hettinger<raymond.hettinger at gmail.com>  wrote:
> >> If someone wants to reorganize code for clarity, I would prefer keeping
> >> it within one file, bringing related functions together and using
> >> comment lines to mark the major sections.  ISTM, this is cleaner than
> >> introducing a new directory and having multiple files that cross-import
> >> one another.
> > +1 (or more)
> Really, you prefer to work in single multi-thousand line modules than 
> cleanly split smaller packages? (Is that how you develop your own 
> projects, out of interest?)

Yes.

Note that this is a more recent tendency, a few years ago I used to
split things pretty finely right off the bat, but I found I wasted a
lot of time on py-file interdependencies doing it that way.

Now I generally only split when the pieces end up generalized enough
that I want to reuse them.  Which, granted, is often enough.  But what
I'm doing in that case is moving code out of a file at the top level of
my library....into a new file at the top level of my library.

Now, it's true that I haven't written any huge applications lately,
but looking at a couple of typical projects the main files run between
1500 and 2000 lines (including comments), and I don't find those to
be particularly big and certainly not awkward.

I do understand the attraction of putting "related stuff" into separate
files.  I just think the balance may have tilted too far in the direction
of nested and could stand to be nudged back toward flat :)

Unittest is only 2600 lines total including comments.  Typical file
sizes are between 200 and 300 lines.  Those feel tiny to me :)

(And email is worse...a number of files only have a single class in them,
and some of those classes consist of maybe 20 lines...)

--
R. David Murray                                      www.bitdance.com


More information about the Python-Dev mailing list