Counting lines of code in a python/django project

Today I had the need to count all the lines of code in a django project. To start with I looked for a python script, then it occurred to me that seeing I'm on a *nix I should be doing this on the command line. So this is what I came up with:

find . -name "*.py" -type f -exec grep . {} \; | wc -l

This counts all the lines in the .py files in the current directory recursively. It does not count blank lines but it does count comments.

Categories: