skip to navigation
skip to content

pycount 0.6.18

Python lines of code counter


* experimental LOC tool (lines of code, a.k.a. SLOC)
* doing this to learn Python
* feel free to raise issues if you find something unusual (the likelihood of someone even looking at this is
very close to zero, so I'm not expecting anything :D)

* add recognition of text files without extension
* add a lightweight option for results charting
* add rules to separate comments based on type of file
* count code lines, comments and blank lines separately
* improve speed, always
* write tests

pip install pycount


You can run the command at any location in your command line
<your code="" dir="">$ pycount

Or you can pass it path arguments
$ pycount ~/My/Repos/Some/Project # single path
$ pycount ~/Some/Code ~/Some/Other/Code # multiple paths
$ pycount ~/ # just one file

Exclude directories or files (exact match)
$ pycount -e test,external
$ pycount -e test,test.c someproject # counts only 'someproject' directory, while excluding 'test' directory and 'test.c' file

Alternatively, you can use the Counter class
from pycount.core import Counter

COUNTER = Counter() # or Counter('some/path') # or you can pass it a list of paths # discovers all unique files for a path
COUNTER.count() # counts all lines of code, using the pre-defined file types which should be considered

to see just the files, file type count and final results, you can use the class attributes
COUNTER.files # lists all the files

COUNTER.file_types # outputs the breakdown of counted file number, by file type
COUNTER.results # outputs the dictionary with all the values that were collected through counting per file type

File Type Py Version Uploaded on Size
pycount-0.6.18-py2.py3-none-any.whl (md5) Python Wheel py2.py3 2017-09-27 11KB
pycount-0.6.18.tar.gz (md5) Source 2017-09-27 8KB