Python Tutorials – Naming conventions

Variable names, function names, class-method names: Use lower case words separated by underscore.

Class Name: Each word starts with Capital letter. No Underscore. (Camel Case)

Constant: Full Upper-case words separated by underscore.

Some common best practices:

Most of the time, make the variable name describes the purpose of the variable. But at the same time do not make it too long.

Do not short the words too much that it is not common and may not be understood my many people.

Avoid using single letter variable names as much as possible. Example: I, j.

Instead describe it with its purpose. Example: counter_word, counter_sent

Always use meaningful names.

Do not use same variable name in same class or function with different scope.


Default image
Asha Ponraj

Data science and Machine Learning enthusiast | Software Developer | Blog Writter

Articles: 84

Leave a Reply