Quick way to calculate lines of code/comments in a collection of Python scripts?

Brandon McCaig bamccaig at gmail.com
Thu Oct 20 16:42:00 EDT 2016


(Sorry for the late reply)

On Wed, Oct 05, 2016 at 01:56:59PM -0400, Malcolm Greene wrote:
> Looking for a quick way to calculate lines of code/comments in a
> collection of Python scripts. This isn't a LOC per day per developer
> type analysis - I'm looking for a metric to quickly judge the complexity
> of a set of scripts I'm inheriting.

There is a CPAN module for a Perl application that calculates
SLOC. You or somebody else may find it useful for this task...

I believe it is packaged for some Linux distros. If applicable
you should be able to just install it:

    sudo aptitude install cloc

Otherwise, if you have Perl installed already (e.g., *nix) and
already have a CPAN client [configured] it should be relatively
easy. cpanm is the most user-friendly client I've used.

    cpanm App::cloc

Alternatively, you can do it with 'cpan' too, but that will
typically prompt you 3 million times... There are a few other
clients available. Use whatever suits you. You could also fetch
the module directly from CPAN and install it manually if so
inclined.

If you have none of these things (e.g., Windows) you could
install the free software Strawberry Perl distribution. It comes
with batteries included. If you're lucky cpanm will just work(tm)
to install it from there.

Hope that helps...

Regards,


-- 
Brandon McCaig <bamccaig at gmail.com> <bambams at castopulence.org>
Castopulence Software <https://www.castopulence.org/>
Blog <http://www.bambams.ca/>
perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }.
q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.};
tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say'

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20161020/970d81bb/attachment.sig>


More information about the Python-list mailing list