我意识到有些方法应该用 来调用(),而另一些则不能。我如何使用 IPython 检查是否使用括号?例如下面的文件scratch.py
import numpy as np
arr = np.random.randn(5)
print arr.sort, "\n"
print arr.sort(), "\n";
print arr.shape, "\n";
print arr.shape(), "\n";
Run Code Online (Sandbox Code Playgroud)
产生这个输出:
<built-in method sort of numpy.ndarray object at 0x7fb4b5312300>
None
(5,)
Traceback (most recent call last):
File "scratch.py", line 8, in <module>
print arr.shape(), "\n";
TypeError: 'tuple' object is not callable
Run Code Online (Sandbox Code Playgroud)