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


Groups > comp.lang.python > #36182

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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <d@davea.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.032
X-Spam-Evidence '*H*': 0.94; '*S*': 0.00; 'configure': 0.04; 'subject:code': 0.07; 'skip:o 60': 0.09; 'subject:number': 0.09; 'subject:python': 0.11; '10:17': 0.16; 'skip:d 60': 0.16; 'skip:o 70': 0.16; 'subject:program': 0.16; 'top-post': 0.16; 'wow,': 0.16; 'wrote:': 0.17; '(or': 0.18; 'skip:= 10': 0.20; 'header:In- Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'chris': 0.28; 'mode': 0.30; 'gets': 0.32; '-----': 0.32; 'to:addr :python-list': 0.33; 'skip:d 20': 0.34; 'text': 0.34; 'list': 0.35; 'email addr:python.org': 0.36; 'too': 0.36; 'two': 0.37; 'why': 0.37; 'subject:: ': 0.38; 'from:': 0.38; 'skip:o 20': 0.38; 'delete': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'your': 0.60; 'most': 0.61; 'email name :python-list': 0.62; 'here': 0.65; 'email,': 0.66; 'header:Reply- To:1': 0.68; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; 'received:74.208.4.194': 0.84; 'thoroughly': 0.84
Date Sat, 05 Jan 2013 10:37:44 -0500
From Dave Angel <d@davea.name>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121011 Thunderbird/16.0.1
MIME-Version 1.0
To python-list@python.org
Subject 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>
In-Reply-To <1357399067.54894.YahooMailNeo@web125504.mail.ne1.yahoo.com>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:hOdHw/uxMY6gBY1gl8/tGAGmulLqtZ0spdS/2fP6Dnz L3OoyOaWdbVRYEbsMhdbQ0A4YZNG3DTcsle0qAkWu7Ddyx7JpX uiDmi8Hth2rJ3yng3YnwXHF9OQKW5letlt1V6RZDPypqlk4RIF 6PT8sidSG8Z96BoLomDquGBzeG8mAZGPcMooGHHXcEIxrUH0ag KaWF6pV3bSxkVcYzkM7e8QyH2IB+Jcrgz477wX9r0spKW6t9w8 QHdYTtOuLRK5ta5V5aXNryotdoZNB/KUPRDH5ODUroHATvXv38 PfuIDe4rNP81BCKh4JkTCAu0q4/IL4AN3XCDUleAh2PSYkHeQ= =
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
Reply-To d@davea.name
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.124.1357400292.2939.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1357400292 news.xs4all.nl 6898 [2001:888:2000:d::a6]:33214
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:36182

Show key headers only | View raw


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.


>
>
> ----- Original Message -----
> From: Chris Angelico <rosuav@gmail.com>
> To: python-list@python.org
Why is the quoted part *after* your message?   Please don't top-post on
this list (or most of them).  It gets too garbled after one or two
generations.



-- 

DaveA

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


Thread

Re: Couting the number of lines of code of a python program Dave Angel <d@davea.name> - 2013-01-05 10:37 -0500
  Re: Couting the number of lines of code of a python program Roy Smith <roy@panix.com> - 2013-01-05 10:40 -0500

csiph-web