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

Discussion in 'Python' started by Chris Angelico, Jan 5, 2013.

  1. 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("'''")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
     
    Chris Angelico, Jan 5, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jazzy
    Replies:
    3
    Views:
    10,631
    Gordon Beaton
    May 25, 2004
  2. chaouche yacine
    Replies:
    0
    Views:
    127
    chaouche yacine
    Jan 5, 2013
  3. Chris Angelico
    Replies:
    0
    Views:
    153
    Chris Angelico
    Jan 5, 2013
  4. Dave Angel
    Replies:
    1
    Views:
    126
    Roy Smith
    Jan 5, 2013
  5. chaouche yacine
    Replies:
    0
    Views:
    119
    chaouche yacine
    Jan 5, 2013
Loading...

Share This Page