Python Rules Of Coding: Naming Conventions

@alrashel · 2020-04-28 06:49 · Education
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


#stem #hive #programming #python #educations4all
Payout: 0.000 HBD
Votes: 13
More interactions (upvote, reblog, reply) coming soon.