我正在使用Pydev
使用Eclipse进行Python开发。
控制点击源代码中的任何模块名称(例如traceback
或subprocess
)会在另一个窗口中打开其源代码。
但是当我控制点击IOError
时,pydev没有显示源代码?
这是为什么? IOError来自哪个模块,为什么它的源不可用?
编辑:
虽然原始问题已得到解答,但我之所以要查看源代码的原因是要查看IOError.errno
可以采用的值。例如,errno
是2
- 我相信 - 无法找到文件时。我希望看到所有其他可能性。
我该怎么做?
答案 0 :(得分:0)
它是一个内置的异常类型,在模块exceptions
中定义:
http://docs.python.org/2/library/exceptions.html#module-exceptions
它是内置的(可能所有定义都在C实现中?)。
对于其他模块,您可以通过以下方式找到加载文件的文件:
>>> import httplib
>>> httplib.__file__
'C:\\Python27\\lib\\httplib.pyc'
但是对于模块异常,你得到:
>>> import exceptions
>>> exceptions.__file__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute '__file__'