IPython 等同于 Clojure find-doc?
IPython equivalent to Clojure find-doc?
在 Clojure repl 中,当忘记确切的函数名称时,我可以使用 find-doc
列出文档或名称中包含我要查找的名称的所有函数。例如:
user=> (xor 1 2)
CompilerException java.lang.RuntimeException: Unable to resolve symbol: xor in this context, compiling:(/tmp/form-init4743234309821191777.clj:1:1)
user=> (find-doc "xor")
-------------------------
clojure.core/bit-xor
([x y] [x y & more])
Bitwise exclusive or
nil
user=> (bit-xor 1 2)
3
如何在 IPython repl 中做同样的事情?
或者在 repl 中搜索函数的 Pythonic 方式是什么?
谢谢
Google 'python xor' 给我(几个选择)一个官方参考页
https://docs.python.org/2/reference/expressions.html
在其中找到的页面将我带到
5.8. Binary bitwise operations
...
xor_expr ::= and_expr | xor_expr "^" and_expr
...
The ^ operator yields the bitwise XOR (exclusive OR) of its arguments, which must be plain or long integers. The arguments are converted to a common type.
该页面有一个搜索框。如果我键入 xor
,我将获得指向 16 个页面的链接。
我看到例如 operator.xor
如果我这样做,在 Ipython
import operator
operator.xor?
In [193]: operator.xor??
Type: builtin_function_or_method
String form: <built-in function xor>
Docstring: xor(a, b) -- Same as a ^ b.
operator.x<tab>
也会显示 operator.xor
。
Ipython 中的 x<tab>
没有帮助,因为没有名为 xor...
的内置函数。由于这是作为运算符实现的,因此搜索将不同于函数。
我经常使用制表符完成,?
和 ??
来查看函数及其代码的文档(如果在 Python 中)。据我所知,Ipython
没有指向一般 Python
文档的链接。
由于我经常使用 numpy
,我还可以搜索 'numpy xor',并获取指向 bitwise_xor
和 [=27= 的 numpy
文档的链接].
np.bit<tab>
带我去
np.bitwise_xor?
<docs for ufunc using the ^ operator>
np.logical_xor
向我展示了一个按元素的数组操作。
在 Clojure repl 中,当忘记确切的函数名称时,我可以使用 find-doc
列出文档或名称中包含我要查找的名称的所有函数。例如:
user=> (xor 1 2)
CompilerException java.lang.RuntimeException: Unable to resolve symbol: xor in this context, compiling:(/tmp/form-init4743234309821191777.clj:1:1)
user=> (find-doc "xor")
-------------------------
clojure.core/bit-xor
([x y] [x y & more])
Bitwise exclusive or
nil
user=> (bit-xor 1 2)
3
如何在 IPython repl 中做同样的事情?
或者在 repl 中搜索函数的 Pythonic 方式是什么? 谢谢
Google 'python xor' 给我(几个选择)一个官方参考页
https://docs.python.org/2/reference/expressions.html
在其中找到的页面将我带到
5.8. Binary bitwise operations
...
xor_expr ::= and_expr | xor_expr "^" and_expr
...
The ^ operator yields the bitwise XOR (exclusive OR) of its arguments, which must be plain or long integers. The arguments are converted to a common type.
该页面有一个搜索框。如果我键入 xor
,我将获得指向 16 个页面的链接。
我看到例如 operator.xor
如果我这样做,在 Ipython
import operator
operator.xor?
In [193]: operator.xor??
Type: builtin_function_or_method
String form: <built-in function xor>
Docstring: xor(a, b) -- Same as a ^ b.
operator.x<tab>
也会显示 operator.xor
。
x<tab>
没有帮助,因为没有名为 xor...
的内置函数。由于这是作为运算符实现的,因此搜索将不同于函数。
我经常使用制表符完成,?
和 ??
来查看函数及其代码的文档(如果在 Python 中)。据我所知,Ipython
没有指向一般 Python
文档的链接。
由于我经常使用 numpy
,我还可以搜索 'numpy xor',并获取指向 bitwise_xor
和 [=27= 的 numpy
文档的链接].
np.bit<tab>
带我去
np.bitwise_xor?
<docs for ufunc using the ^ operator>
np.logical_xor
向我展示了一个按元素的数组操作。