【问题标题】:IPython Notebook Tab-Complete -- Show DocstringIPython Notebook Tab-Complete -- 显示文档字符串
【发布时间】:2014-07-04 10:02:44
【问题描述】:

我刚刚升级到 IPython 2.0.0,tab-complete 的行为似乎发生了变化。 (使用 pyreadline 2.0,根据this question 可能很重要)。

以前,如果我在function_name( 之后按 TAB,IPython 会显示该函数的文档字符串。

现在,我只看到一个下拉列表,我猜想是命名空间中的所有内容,包括:

  • 错误类型
  • 目录中其他笔记本的名称
  • IPython 魔术函数
  • 我定义的其他函数

旧的行为非常有用——我怎样才能恢复它(没有恢复到早期的 IPython 版本)?

【问题讨论】:

  • 现在可以使用 shift-tab 来获得它。
  • 这对我不起作用。在 mac 上可能会有所不同吗?
  • 嗯,今天有效。 %magic 确实。
  • Shift+tab 对我来说适用于文档字符串,但不适用于自动完成......编辑:哎呀,自动完成现在只是标签......但它似乎工作得非常糟糕!

标签: python jupyter-notebook ipython


【解决方案1】:

显然它现在是 Shift-Tab。谢谢@Thomas K。

【讨论】:

    【解决方案2】:

    对于自动完成,您可以在笔记本的任何位置使用此行;

    %config Completer.use_jedi = False
    

    使用此行将帮助您能够使用 tab 进行自动完成。

    如果我想打印出文档——例如,如果我想打印出SVC 的文档,这样我就可以添加超参数变量。

    from sklearn.svm import SVC
    

    那么,

    SVC?
    

    输出

    Init signature:
    SVC(
        *,
        C=1.0,
        kernel='rbf',
        degree=3,
        gamma='scale',
        coef0=0.0,
        shrinking=True,
        probability=False,
        tol=0.001,
        cache_size=200,
        class_weight=None,
        verbose=False,
        max_iter=-1,
        decision_function_shape='ovr',
        break_ties=False,
        random_state=None,
    )
    Docstring:     
    C-Support Vector Classification.
    
    The implementation is based on libsvm. The fit time scales at least
    quadratically with the number of samples and maybe impractical
    beyond tens of thousands of samples. For large datasets
    consider using :class:`sklearn.SVM.LinearSVC` or
    :class:`sklearn.linear_model.SGDClassifier` instead, possibly after a
    :class:`sklearn.kernel_approximation.Nystroem` transformer.
    
    The multiclass support is handled according to a one-vs-one scheme.
    
    For details on the precise mathematical formulation of the provided
    kernel functions and how `gamma`, `coef0` and `degree` affect each
    other, see the corresponding section in the narrative documentation:
    :ref:`svm_kernels`.
    
    ...
    

    对于 Shallowing,您可以使用 Shift + Tab 显示任何类的文档,或 ()中的函数@

    希望有帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-11
      • 2016-07-20
      • 2019-03-09
      • 1970-01-01
      • 1970-01-01
      • 2012-02-18
      • 2023-04-02
      • 2015-08-02
      相关资源
      最近更新 更多