python - 将 '?' 用于对象信息如何工作?

标签 python function ipython

<分区>

我在 Python decorator to keep signature and user defined attribute 中偶然发现了以下语法:

> def func():
...     return "Hello World!"
...
> func?
Signature: func()
Docstring: <no docstring>
File:      ~/<ipython-input-8-934f46134434>
Type:      function

在我的 Python Shell 中尝试相同的操作,无论是 2 还是 3,都只会引发 SyntaxError。那么这到底是什么,是否特定于某些 shell?

最佳答案

这是一个 IPython 特性,描述为 here

Typing ?word or word? prints detailed information about an object.
...
Typing ??word or word?? gives access to the full information, including the source code where possible. Long strings are not snipped.

关于python - 将 '?' 用于对象信息如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48836596/

相关文章:

python - 发生 break 语句时生成器销毁

python - 发送至交易所 : How to Disable Disable Lossy Conversion of HTML to RTF?

python - 正则表达式将字符添加到匹配的字符串

postgresql - 在函数postgres中分配参数

python-3.x - python pandas条件累积总和

ipython - 如何将键盘快捷键永久添加到 Jupyter (ipython) 笔记本?

python - 是否可以知道您是否在 ipython 中?

python - 在 python 中传递命令行 arg 的实现不起作用

c++ - 从外部函数/类设置动态数组的新大小?

mysql - 在 MySQL 中使用和创建函数