Hive-blogger avatar

Python Rules Of Coding: Naming Conventions

alrashel

Published: 28 Apr 2020 › Updated: 28 Apr 2020Python Rules Of Coding: Naming Conventions

Python Rules Of Coding: Naming Conventions

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

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

Leave Python Rules Of Coding: Naming Conventions to:

Written by

Passionate software developer and interests in Travelling, Blogging, Photography and active lifestyle.

Read more #stem posts


Best Posts From Hive-blogger

We have not curated any of alrashel's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From Hive-blogger