对于threading.Thread,有两个方法似乎具有相同的功能:
is_alive和isAlive
对于threading.Event,有以下方法:
is_set和isSet
类似threading模块,这些方法同样可用
currentThread和current_threadactive_count和activeCount
所以,问题是,尽管看起来这两种方法具有相同的功能,为什么有两种方法可用?
此外,哪个更好?
请您参考如下方法:
Python 通常使用 lowercase or lowercase_with_underscores for method and function names . threading 模块在首次添加到 Python 时错误地使用了 mixedCase 作为许多名称。他们后来添加了 lowercase_with_underscores 名称作为与 Python 其余部分风格一致的别名。
一般情况下,使用lowercase_with_underscores 名称,除非您的代码需要在 Python 2.5 或更早版本上运行(固定名称是在 2.6 中添加的)。也就是说,the docs note :
Note: Starting with Python 2.6, this module provides PEP 8 compliant aliases and properties to replace the camelCase names that were inspired by Java’s threading API. This updated API is compatible with that of the multiprocessing module. However, no schedule has been set for the deprecation of the camelCase names and they remain fully supported in both Python 2.x and 3.x.
