-1

I'm doing research on software engineering.

I need to measure how many lines each function or class has in each file.

Another interesting metric would be the number of functions and the cyclomatic complexity of each one.

Optionwiz
  • 326
  • 1
  • 4
  • 13
  • Does this answer your question? [Good way to count number of functions of a python file, given path](https://stackoverflow.com/questions/37514636/good-way-to-count-number-of-functions-of-a-python-file-given-path) – L8R Oct 25 '22 at 00:23

1 Answers1

0

You can do something like this

import inspect

def test(param1, param2):
    print(param1, param2)
    print(1+1)

inspect.getsource(test)
# 'def test(param1, param2):\n    print(param1, param2)\n    print(1+1)\n'

inspect.getsource(test).count("\n")
# 3