newbie question
Freller Alex
alex.freller at gmx.at
Thu Jul 5 04:27:03 EDT 2001
thanks a lot for your support. that one worked for me very nice.
Emile van Sebille schrieb:
>
> 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