Python: code statistics

前端 未结 3 1939
花落未央
花落未央 2021-02-07 22:27

Do you know if there\'s a Python library that generates statistics about code? I\'m thinking about pointing to a package and getting number of classes, functions, methods, docbl

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-07 23:33

    Maybe Tahar can help, it displays statistics about how long each function, method, class and module are (in lines of code). However, since it's using the inspect module, it may run in unexpected ways if one of the module it analyzes launches a GUI or something like that.

    I'll switch to using AST someday, although I don't know if AST can provide a service that is similar to inspect.getsourcelines() ?

    (EDIT)

    Mergou (the rewrite of tahar using the tokenize module) is in alpha, here's a video of it in action : http://www.youtube.com/watch?v=PI0iBZmInFU&feature=youtu.be

提交回复
热议问题