我有一个没有 argparse
的 python 文件在其 __main__
中实现,但是,我有兴趣从命令行查看其中实现的功能和模块。我很想编写一个函数来执行此类探索,但我想首先了解它是否已经可用。
编辑1:为了使其更具体,我对函数和类的名称及其文档感兴趣。
最佳答案
您可能正在寻找类似 python-fire 的工具.
来自存储库:
Python Fire is a library for automatically generating command line interfaces (CLIs) from absolutely any Python object. [...] Python Fire helps with exploring existing code or turning other people's code into a CLI.
它可以作为 pip 上的包提供。
关于python - 如何从命令行探索 python 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70369781/