Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #36181

Re: Couting the number of lines of code of a python program

References <1357394154.35596.YahooMailNeo@web125506.mail.ne1.yahoo.com> <CAPTjJmrfZZ0aCoXA2biwKDFdKVupKxU0Jugpuck=L===Vz6=kA@mail.gmail.com> <1357399067.54894.YahooMailNeo@web125504.mail.ne1.yahoo.com>
Date 2013-01-06 02:25 +1100
Subject Re: Couting the number of lines of code of a python program
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.123.1357399567.2939.python-list@python.org> (permalink)

Show all headers | View raw


On Sun, Jan 6, 2013 at 2:17 AM, chaouche yacine
<yacinechaouche@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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Couting the number of lines of code of a python program Chris Angelico <rosuav@gmail.com> - 2013-01-06 02:25 +1100

csiph-web