[Tutor] text module

lumbricus@gmx.net lumbricus@gmx.net
Fri, 30 Aug 2002 19:18:22 +0200 (MEST)


Hi!

> (called it the text module, any better
> ideas?) 

Yes - wc.py, because it does just, what the *NIX wc(1) (word count)
command does :-)

> that will do all of this.  Before I got to far into this I
> thought I would ask people opinions on this idea and what I have so
> far.
> 
> First of all I would appeciate it if you could test what I have so far.
>  Here is the source (text.py):

[ snip ]
 
> def LineCount(location):
>     subj = file(location, "r")
>     body = subj.readlines()
>     subj.close()
> 
>     lines = 0
>     for each in body:
>         lines = lines + 1
>     print lines

Why not
def LineCount(location):
	subj=file(location, "r")
	body=subj.readlines()
	subj.close()
	return len(body)

[ snip ]

HTH, HAND
J"o!

-- 

-- 
Wir beschliessen etwas, stellen das dann in
den Raum und warten dann einige Zeit ab, was
passiert. Wenn es dann kein grosses Geschrei
gibt und keine Aufstaende, weil die meisten
gar nicht begreifen, was da beschlossen
wurde, dann machen wir weiter - Schritt fuer
Schritt, bis es kein Zurueck mehr gibt. 
   -- J-C Juncker

GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net