In article ,
Dave Angel wrote:
> On 01/05/2013 10:17 AM, chaouche yacine wrote:
> >
>
>
> >
> > Here is my implementation :
> >
> > defcount_loc(lines):nb_lines =0docstring =Falseforline inlines:line
> > =line.strip()ifline ==""\ orline.startswith("#")\ ordocstring
> > andnot(line.startswit
ing or ending docstring
elif line.startswith('"""') or line.startswith("'''"):
docstring = not docstring
continue
else:
nb_lines += 1
return nb_lines
- Original Message -
From: Chr
On 01/05/2013 10:17 AM, chaouche yacine wrote:
>
>
> Here is my implementation :
>
> defcount_loc(lines):nb_lines =0docstring =Falseforline inlines:line
> =line.strip()ifline ==""\ orline.startswith("#")\ ordocstring
> andnot(line.startswith('"""')orline.startswith("'''"))\
> or(line.startswi
On Sun, Jan 6, 2013 at 2:17 AM, chaouche yacine
wrote:
> defcount_loc(lines):nb_lines =0docstring =Falseforline inlines:line
> =line.strip()ifline ==""\ orline.startswith("#")\ ordocstring
> andnot(line.startswith('"""')orline.startswith("'''"))\
> or(line.startswith("'''")andline.endswith("'''
ith("'''"):docstring
=notdocstring continueelse:nb_lines +=1returnnb_lines
- Original Message -
From: Chris Angelico
To: python-list@python.org
Cc:
Sent: Saturday, January 5, 2013 3:09 PM
Subject: Re: Couting the number of lines of code of a python program
On
On Sun, Jan 6, 2013 at 12:55 AM, chaouche yacine
wrote:
> The
> problem is that I'm using the inspect module, because it provides a
> nice function inspect.getsourcelines that takes a python object and
> return its number of lines of code. BUT, it works on live objects, that
> means one has to fi
Hello.
I'v written a small script that prints the number of lines
of code of a python program to stdout (by module, function, class and
method), the sources are available online here
https://www.assembla.com/code/tahar/subversion/nodes. The readme has an example
usage as well as a trace of