2

I have a directory with many subdirectories with Python source code which correspond to a Python package. I want to count how many classes and root classes (top of hierarchies) are contained in these directories/package. Any easy way to do this?

Ray Doyle
  • 829
  • 1
  • 6
  • 8

1 Answers1

1

You don't need to write a Python script for that. From the command line type:

grep -c "^class " *.py

and will return the number of classes in the current directory for each .py file. To find if a class is a top class I'm afraid you will have to import each and query each module.

Hernán
  • 1,749
  • 10
  • 12