Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #36171
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <yacinechaouche@yahoo.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'importing': 0.04; 'irc': 0.05; 'function,': 0.07; 'objects,': 0.07; 'subject:code': 0.07; 'python': 0.09; 'ast': 0.09; 'stdout': 0.09; 'subject:number': 0.09; 'advance': 0.10; 'gui': 0.11; 'subject:python': 0.11; 'subject:program': 0.16; 'url:assembla': 0.16; 'module,': 0.17; 'module': 0.19; 'code.': 0.20; 'to:name:python-list@python.org': 0.20; 'written': 0.20; 'import': 0.21; '(by': 0.22; 'trace': 0.22; 'help.': 0.22; 'example': 0.23; 'script': 0.24; 'question': 0.27; 'module.': 0.27; 'lines': 0.28; 'inspect': 0.29; 'prints': 0.29; 'received:98.138.87': 0.29; 'url:code': 0.29; 'class': 0.29; "i'm": 0.29; 'function': 0.30; 'code': 0.31; 'sources': 0.32; 'problem': 0.33; 'to:addr:python-list': 0.33; 'reply- to:addr:yahoo.com': 0.34; 'thanks': 0.34; 'process,': 0.35; 'object': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'takes': 0.39; 'little': 0.39; 'help': 0.40; 'your': 0.60; 'first': 0.61; 'side': 0.61; 'header:Reply-To:1': 0.68; 'online': 0.70; 'received:98.138.226': 0.91 |
| X-Yahoo-Newman-Property | ymail-3 |
| X-Yahoo-Newman-Id | 927748.89125.bm@omp1005.mail.ne1.yahoo.com |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1357394154; bh=BlNDPaGWNCv03g+pTeWr+zEHyYe/gzn+CCi0RcW86kM=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:Message-ID:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=44mDC1KzsHgDsSRNeXcnDQEliYNKy8CKXnAnGir0AoAfZH7CfWN/4/WDNP0CuU2VJeurroxWFA7jNOeQ9/Ly2TrS8/N/rZKVnUBrSbqad+UxVOFk8/ksQwF9JSi1YZ9cxRbRjtWsaCBFsA3qDKxSeQruIQ3+jV+TPLXFSDCiz9A= |
| DomainKey-Signature | a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:Message-ID:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=g4T6rUfsMGDSh/+KZjMuU931YuZwIoiv6yyO21gWROOWkhLlcL1oHBzbhNNC+HAj5JTLEtyXCB4n209FU7RKlKQ9GZVWqIkU5gpgjGf4nzwY3uQge8J3SbzRev6SBFaLDK9ATfOrmiMMdhyiOCdDzZC5kqIAW/rw172lX/6T4vg=; |
| X-YMail-OSG | 9KnX8SYVM1kQ3YqdjpqQb8wKc_oC5UF3yT_73XgrmKJb2wb rIOnhSQyFhs9KwSJ6usg54Ji9OUK57Zl_1G56Og6zoA742P_UJqZ7NSk_IgX bwl3gP45yCYyXCsuDpoPMZS0YxE1lQ507dwLLM7adR3w0YSevTbmWUd11has VkRQsyMhmYXUwzsv.4CJlhrHNxkjOMUCRIFaNlUkxVYLjnOD0ilgCi.V7NAu iUgc_mbMIsbHYV59w9lTTdXYQOpcqpagSIxrmsW_pUrQVr_f_zxFU10xvJQg QJemHLZ.VRoVlYYuQ6_HP1gh73._Vgen7asDuLY4ofDzfDtUL89BL3zohP03 zmuUEBe3R.btqZTMKdjnCIfepMP9.3k6LJCrQSXC3eQW52kkYRuW8afdzq3S wHtVTh81rF0Pcr_4ooPD3wBPxmVusRKd7hg1Oiwt8Hj8A6A4OqsuGMYHp51I qX1nfRefgJ3in5QoZJuLJSC_PLJJdoP0UIoJiFMOaIZejNnEv9gpeNQCTFDz jgULpZsXkcMwSXDGQAxcIZ858Tz3k.p.RFa7_D4NRnjxxDmPajNxvfJ24g6S .o141JyQimZ38KrBCcGRpCFHhDWGTOR2rogGhx9VwrqqGrojP9g-- |
| X-Rocket-MIMEInfo | 001.001, ICAKSGVsbG8uCgpJJ3Ygd3JpdHRlbiBhIHNtYWxsIHNjcmlwdCB0aGF0IHByaW50cyB0aGUgbnVtYmVyIG9mIGxpbmVzCiBvZiBjb2RlIG9mIGEgcHl0aG9uIHByb2dyYW0gdG8gc3Rkb3V0IChieSBtb2R1bGUsIGZ1bmN0aW9uLCBjbGFzcyBhbmQgCm1ldGhvZCksIHRoZSBzb3VyY2VzIGFyZSBhdmFpbGFibGUgb25saW5lIGhlcmXCoCBodHRwczovL3d3dy5hc3NlbWJsYS5jb20vY29kZS90YWhhci9zdWJ2ZXJzaW9uL25vZGVzLiBUaGUgcmVhZG1lIGhhcyBhbiBleGFtcGxlIHVzYWdlIGFzIHdlbGwgYXMgYSABMAEBAQE- |
| X-Mailer | YahooMailWebService/0.8.129.483 |
| Date | Sat, 5 Jan 2013 05:55:54 -0800 (PST) |
| From | chaouche yacine <yacinechaouche@yahoo.com> |
| Subject | Couting the number of lines of code of a python program |
| To | "python-list@python.org" <python-list@python.org> |
| MIME-Version | 1.0 |
| 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 |
| Reply-To | chaouche yacine <yacinechaouche@yahoo.com> |
| 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.118.1357394322.2939.python-list@python.org> (permalink) |
| Lines | 15 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1357394322 news.xs4all.nl 6913 [2001:888:2000:d::a6]:55072 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:36171 |
Show key headers only | View raw
Hello. I'v written a small script that prints the number of lines of code of a python program to stdout (by module, function, class and method), the sources are available online hereĀ https://www.assembla.com/code/tahar/subversion/nodes. The readme has an example usage as well as a trace of what the script prints. The problem is that I'm using the inspect module, because it provides a nice function inspect.getsourcelines that takes a python object and return its number of lines of code. BUT, it works on live objects, that means one has to first import the module he wants to process, and this can have side effects (example : GUI programs). So my question is how can one count the number of lines of code of a python program without importing it (static code analysis) ? Some people on IRC advised me to look for the AST module. Can you give me a little help on how to use this module to count the number of lines of code of a function/method ? Thanks in advance for your help.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Couting the number of lines of code of a python program chaouche yacine <yacinechaouche@yahoo.com> - 2013-01-05 05:55 -0800
csiph-web