Python Rules Of Coding: Naming Conventions

in Education4 years ago
Previous

Python Rules Of Coding: Indentation

code-1084923_1280.png

Source

Python Rules Of Coding

Naming Conventions :

There are a lot of different Python naming conventions. It is recommended to apply these rules or conventions to our code. If we want to ensure our code's better quality, readability, and reusability. Applying name guidelines we can improve the performance and robustness of our Python Applications.

The rules or conventions :

  1. Always use a meaningful name.
  2. lowercase or lower_case_with_underscores. Ex. kalil, user_info
  3. Avoid too simple name like 'X', 'x', 'Y'
  4. The name of package, module in Python always should be lower case and short, if needs use an underscore as a separator to join multiple words and it should be a meaningful or logical name. Ex. csspec or css_spec
  5. Class names in Python follow the CapWords convention. We can also name a class like a function if the class is callable.
  6. The naming of the global variable, functions, and methods should follow the lowercase naming convention.
  7. Use 'self' as the first argument for an instance method and 'cls' as the first argument for class methods.
  8. Constants' names in Python always follow the UPPERCASE convention. We can use underscore(_) for joining multiple words.

Next

comments, String Quotes, and User Documentation

------------------------------------

Sort:  

I used to study since python is the most flexible programming language.

Python is quite flexible indeed (in terms of applications).

Nice insight on python rule of coding. This is the kind of content we support on gitplait. You can post via the community for others to learn, and you can as well learn through other contents that involves development. There is more to gitplait. https://gitplait.tech
https://hive.blog/trending/hive-103590. Would be glad to have you around. You can also join the discord server https://discord.gg/mD8ez2.