如何在Jupyter中转到函数定义?
我想要Visual Studio的f12或Eclipse的ctrl + click之类的东西。
我很难相信这不存在,但找不到
最佳答案
我不知道这种功能适用于所有内核。
如果您使用的是Python内核并安装了ipython,则可以使用检查功能:
%pdoc <object>
: Print (or run through a pager if too long) the docstring for an object. If the given object is a class, it will print both the class and theconstructor docstrings.%pdef <object>
: Print the call signature for any callable object. If the object is a class, print the constructor information.%psource <object>
: Print (or run through a pager if too long) the source code for an object.%pfile <object>
: Show the entire source file where an object was defined via a pager, opening it at the line where the object definition begins.%who/%whos
: These functions give information about identifiers you have defined interactively (not things you loaded or defined in your configuration files). %who just prints a list of identifiers and %whos prints a table with some basic details about each identifier.Typing
??word
orword??
gives access to the full information, including the source code where possible. Long strings are not snipped.
使用范例
In [4]: pd.DataFrame?
In [5]: pd.DataFrame??
In [6]: %pdef pd.Dataframe
Object `pd.Dataframe` not found.
In [7]: %pdef pd.DataFrame
Class constructor information:
pd.DataFrame(data=None, index=None, columns=None, dtype=None, copy=False)
In [8]: %pdoc pd.DataFrame
In [9]: %pfile pd.DataFrame
资源
Dynamic object information
关于python - 如何在Jupyter笔记本中转到函数的定义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53451028/