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

Question:

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

Asked By: user697911

||

Answers:

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

Answered By: Charlie

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) 
Answered By: Chinny84
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.