How can I check source code of a module in Jupyter notebook?

前端 未结 2 1110
面向向阳花
面向向阳花 2021-02-05 04:11

For example, I want to check the source code of a python library, directly in the notebook, is there a way to do that?

Thank you

2条回答
  •  终归单人心
    2021-02-05 04:44

    You can use inspect module (which is built in) - for example you can see the tree module below from scikit-learn.

    import inspect
    from sklearn import tree
    inspect.getsourcelines(tree.tree) 
    

提交回复
热议问题