Couting the number of lines of code of a python program

Chris Angelico rosuav at gmail.com
Sat Jan 5 16:25:58 CET 2013


On Sun, Jan 6, 2013 at 2:17 AM, chaouche yacine
<yacinechaouche at yahoo.com> 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("'''")andlen(line)>3)\ or(line.startswith('"""')andline.endswith('"""')andlen(line)>3):continue# this is either a starting or ending docstringelifline.startswith('"""')orline.startswith("'''"):docstring =notdocstring continueelse:nb_lines +=1returnnb_lines

Ow-what? Something's gone wrong with all your whitespace, I think...
can you paste again please?

ChrisA



More information about the Python-list mailing list