在 Python 中,异常是类,并且也是如此。例如:OSError
.
但是,也有一些异常(exception),例如 socket module 中的异常(exception)情况。 ,以小写形式命名。例如:socket.timeout
, socket.error
.
这是为什么?
最佳答案
根据文档,
exception socket.error A deprecated alias of OSError.
Changed in version 3.3: Following PEP 3151, this class was made an alias of OSError.
PEP 3151 says
while standard exception types live in the root namespace, they are visually distinguished by the fact that they use the CamelCase convention, while almost all other builtins use lowercase naming (except True, False, None, Ellipsis and NotImplemented)
关于python - 为什么有些 Python 异常是小写的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59617184/