number of lines in a file
jeff at ccvcorp.com
Fri Mar 29 20:39:56 CET 2002
In article <slrnaa9b09.i04.philh at comuno.freeserve.co.uk>,
philh at comuno.freeserve.co.uk says...
> On Fri, 29 Mar 2002 06:36:14 -0800, Emile van Sebille <emile at fenx.com> wrote:
> >Joseph Youssef
> >> hello, I am nwe to Python and I'm trying to write this
> >> script but I need it to check how many lines is in
> >> the file and I don't know how so I'm hoping someone
> >> could tell me.
> os.system("wc -l %s" % filename)
Except that this is platform-specific for *nix, whereas
len(file.readlines()) works on all Python platforms.
More information about the Python-list