Consider the naming convention used for different types of containers in the Python standard library:
Why do some methods follow camel case, but others like deque
and defaultdict
don't? How are these methods different from each other in a way that would explain this difference?
If it's because at some point the convention changed, why wouldn't the module e.g. provide alias them with camel case names to old names as well?
modules (filenames) should have short, all-lowercase names, and they can contain underscores; packages (directories) should have short, all-lowercase names, preferably without underscores; classes should use the CapWords convention.
In Python, the names of variables and functions should be lowercase. Individual words can be separated by underscores when needed. This will improve readability within your code. Method names should follow the same conventions as function names.
Usually in python, class names follow the "pascal" case convention, methods / functions follow the "snake" case convention. But here is a official reference from https://www.python.org/dev/peps/pep-0008/:
Package and Module Names
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With