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

前端 未结 2 1100
面向向阳花
面向向阳花 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) 
    
    0 讨论(0)
  • 2021-02-05 04:58

    Type the fully qualified function name, then type ??.

    0 讨论(0)
提交回复
热议问题