Modules should have short, all-lowercase
names. Underscores can be used in the module name if it improves
readability. Python packages should also have short, all-lowercase
names, although the use of underscores is discouraged.
When an extension module written in C or C++ has an accompanying
Python module that provides a higher level (e.g. more object oriented)
interface, the C/C++ module has a leading underscore (e.g. _socket).
Class names
Class names should normally use the CapWords convention.
The naming convention for functions may be used instead in cases where
the interface is documented and used primarily as a callable.
Note that there is a separate convention for builtin names: most
builtin names are single words (or two words run together), with the
CapWords convention used only for exception names and builtin
constants.
通常在python中,类名遵循“pascal”case约定,方法/函数遵循“snake”case约定。 但以下是来自https://www.python.org/dev/peps/pep-0008/的官方参考:
相关问题 更多 >
编程相关推荐