From: Michele Simionato on
I need a small utility to count the lines of Python code in a
directory, traversing subdirectories and ignoring comments and
docstrings. I am sure there is already something doing that, what do
you suggest?

TIA,

Michele Simionato
From: Mark Hammond on
On 21/01/2010 5:51 PM, Michele Simionato wrote:
> I need a small utility to count the lines of Python code in a
> directory, traversing subdirectories and ignoring comments and
> docstrings. I am sure there is already something doing that, what do
> you suggest?

I suggest typing your subject line into google and hitting the "I feel
lucky" button :)

HTH,

Mark
From: Ben Finney on
Michele Simionato <michele.simionato(a)gmail.com> writes:

> I need a small utility to count the lines of Python code in a
> directory, traversing subdirectories and ignoring comments and
> docstrings. I am sure there is already something doing that, what do
> you suggest?

Any of the static code checkers ('pylint', 'pyflakes', etc.) would
already be doing this.

You would at least be able to crib from them, maybe import the
functionality; ideally they can directly report what you want to see.

--
\ “My business is to teach my aspirations to conform themselves |
`\ to fact, not to try and make facts harmonise with my |
_o__) aspirations.“ —Thomas Henry Huxley, 1860-09-23 |
Ben Finney
From: Michele Simionato on
I did not known about cloc, it does more that I need, but it looks
cool (it is perl and not Python, by who cares? ;)

Thanks,

Michele
From: Michele Simionato on
On Jan 21, 8:12 am, Ben Finney <ben+pyt...(a)benfinney.id.au> wrote:
> Michele Simionato <michele.simion...(a)gmail.com> writes:
> > I need a small utility to count the lines of Python code in a
> > directory, traversing subdirectories and ignoring comments and
> > docstrings. I am sure there is already something doing that, what do
> > you suggest?
>
> Any of the static code checkers (‘pylint’, ‘pyflakes’, etc.) would
> already be doing this.

pylint does too many things, I want something fast that just counts
the lines and can be run on thousands of files at once.
cloc seems fine, I have just tried on 2,000 files and it gives me a
report in just a few seconds.