Count number of classes and class hierarchies in a Python package
-
21-01-2021 - |
문제
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?
해결책
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.
제휴하지 않습니다 StackOverflow