Count lines of code in directory using Python
Here’s a function I wrote to count all lines of code in a python package and print an informative output. It will count all lines in all .py import os def countlines(start, lines=0, header=True, begin_start=None): if header: print(‘{:>10} |{:>10} | {:<20}’.format(‘ADDED’, ‘TOTAL’, ‘FILE’)) print(‘{:->11}|{:->11}|{:->20}’.format(”, ”, ”)) for thing in os.listdir(start): thing = os.path.join(start, thing) if … Read more