newbie question
Emile van Sebille
emile at fenx.com
Wed Jul 4 10:00:23 EDT 2001
import glob
count = 0
for f in glob.glob(r"f:\python21\lib\*.py"):
count += len(open(f).readlines())
print count
oops... missed the sub-directory part...
count = [0]
import os
def addUpLines(count, dirName, fileList):
for f in fileList:
if f[-3:] == ".py":
count[0] += len(open("%s%s%s" % (dirName, os.sep,
f)).readlines())
print dirName, count,'\n\n'
print os.path.walk(r"f:\python21\lib", addUpLines, count)
print count[0]
HTH,
--
Emile van Sebille
emile at fenx.com
---------
"Freller Alex" <alex.freller at gmx.at> wrote in message
news:3B42A1A3.2A7793CC at gmx.at...
> I would like to program a python script that parses a directory and its
> subdirectorys after specific files (*.pl) and count their linenumbers.
>
> thanks,
>
> alex
More information about the Python-list
mailing list