[Tutor] question about importing threads
Alan Gauld
alan.gauld at btinternet.com
Sat Dec 30 20:16:54 CET 2006
"shawn bright" <nephish at gmail.com> wrote i
> testing this right away. This long a .py script is becomming a
> headache and
> i think it will be easier by far if it is pulled apart somewhat.
As a general rule of thumb, any Python script (or any programming
language file for that matter!) that gets longer than 4 or 5 hundred
lines should be looked at closely in terms of splitting it into
modules.
There are a few (very few) times where I've seen a thousand line
file that was justified, but nearly any time you get beyond 500
lines you should be splitting things up - especially in high level
languages like Python where the methods/functions tend to be
short anyway.
FWIW
A quick check of the Python standard library shows the
average file size there to be: 459 lines(*) And that's pretty
high IMHO!
There are 19 files over a thousand lines and the biggest file
is over 3000 lines... which seems way too big to me!
But that's out of 188 files...
(*)
Cygwin; Python 2.4
In case you want to repeat for your version I used:
>>> libs = [len(open(f).readlines()) for f in glob('*.py')]
>>> print sum(libs)/len(libs)
>>> print max(libs)
>>> print len([s for s in libs if s>1000])
Alan G
More information about the Tutor
mailing list