How can you find unused functions in Python code?

前端 未结 5 1961
时光取名叫无心
时光取名叫无心 2020-11-27 03:31

So you\'ve got some legacy code lying around in a fairly hefty project. How can you find and delete dead functions?

I\'ve seen these two references: Find unused code

5条回答
  •  北海茫月
    2020-11-27 04:15

    its not only searching function names, but also all the imported packages not in use. you need to search the code for all the imported packages (including aliases) and search used functions, then create a list of the specific imports from each package (example instead of import os, replace with from os import listdir, getcwd,......)

提交回复
热议问题