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

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 <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.014
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'subject:code': 0.07; 'skip:o 60': 0.09; 'subject:number': 0.09; 'subject:python': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'skip:d 60': 0.16; 'skip:o 70': 0.16; 'subject:program': 0.16; 'wrote:': 0.17; 'jan': 0.18; 'skip:= 10': 0.20; 'please?': 0.22; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'message- id:@mail.gmail.com': 0.27; 'received:209.85.212': 0.28; 'to:addr :python-list': 0.33; 'skip:d 20': 0.34; 'received:google.com': 0.34; 'wrong': 0.34; 'received:209.85': 0.35; 'received:209': 0.37; 'subject:: ': 0.38; 'skip:o 20': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'gone': 0.64; '2013': 0.84; 'think...': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=bPL0TqDS70seQqLV8G0cv6mktnl5vRn1AnM+k9/31sk=; b=yRcE9Z0wNCQygjvNvaVNSwdIabZOheo30ljHrRyIzBu1uu4nlVv59k2L9k4FcussHr eNESkmo9EkduxZnu5MOsGFzssVHhteZ+W5lWCUNPdXkAsefl2OMJ1kK4ic1zP0dnYkeC 3yIZtZKvs9bnoXs6dDlQISCFu3eJ6CyZY6EZYhSS+PIHiRGa2w2xGy+yux4R6Xc/QFBq kscrtmXmxsMyYpXuPRIPlJ8P5eCgHxr97Oa9cbCswkjQSsmlMRu29jYP65aHyP3X3T5H Hmz7iZ0hjy28nVXgnDHaoXGylMNIItdO7wdiKXhzEmxYofpnEME/phY8gA64Dp8ZUgAO 2AfQ==
MIME-Version 1.0
In-Reply-To <1357399067.54894.YahooMailNeo@web125504.mail.ne1.yahoo.com>
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 Sun, 6 Jan 2013 02:25:58 +1100
Subject Re: Couting the number of lines of code of a python program
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
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.123.1357399567.2939.python-list@python.org> (permalink)
Lines 14
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1357399567 news.xs4all.nl 6840 [2001:888:2000:d::a6]:58088
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:36181

Show key headers only | 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