I'm trying to find the count of lines of codes within a class in a python file .. I used the len(inspect.getsourcelines(b)[0]) to return the number of lines of code for each class in the file but the problem it counts comments and doc string in addition to the code lines .. is there any way to discard the comments and doc string??
import inspect
import foo
for a,b in inspect.getmembers(foo):
if inspect.isclass(b):
print(a)
print(len(inspect.getsourcelines(b)[0]))