Count number of classes and class hierarchies in a Python package
-
21-01-2021 - |
Domanda
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?
Soluzione
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.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow