Couting the number of lines of code of a python program

Roy Smith roy at panix.com
Sat Jan 5 16:40:42 CET 2013


In article <mailman.124.1357400292.2939.python-list at python.org>,
 Dave Angel <d at davea.name> wrote:

> On 01/05/2013 10:17 AM, chaouche yacine wrote:
> > <snip>
> 
> 
> >
> > 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.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
> 
> Wow, this is thoroughly garbled.  Please configure your email (yahoo?)
> to use text mode email, to not delete spaces, to honor newlines, etc.

Nice to know that wasn't just another case of my using an antiquated 
news reader :-)



More information about the Python-list mailing list