Regarding the naming of variables, this is another topic that can easily lead to programmer debate. How can the naming be more readable, easy to write, and clear? There are many opinions.

In this story of “Why Python” series, we will focus on the connection method in variable namings:

The question we want to answer is- why does Python recommend the snake-like nomenclature?

First of all, for single characters or words (for example A, PYTHON, BOY), when they are used as variable names, there are roughly all lower case, all upper case, and first letter upper case.

However, programming languages ​​usually need to use multiple words or symbols to express a richer meaning in variable names**. **English is used to using spaces to separate words, but this usage will cause some trouble in the programming language, so programmers have created other methods:

  • Snake case
  • Camel case nomenclature (camel case)
  • Hungarian nomenclature (HN case)
  • Pascal case
  • Spinal nomenclature (spinal case)
  • Free nomenclature (studly caps)
  • Nomenclature

In general, these nomenclatures are to overcome the spaces between words and to connect them, and finally achieve the effect of creating a new “word”.

If you rank according to the number of audiences and popularity, there is no doubt that the top two names are camel nomenclature and snake-case nomenclature.

We can simply compare their advantages and disadvantages:

Readability:

  • Snake-shaped nomenclature uses underscore to widen the word distance, which is more clear and easy to read
  • The variable name of the camel hump nomenclature is compact, saving line width

Ease of writing

  • The camel case nomenclature is distinguished by uppercase and lowercase, and no additional identifier is introduced;
  • The snake-case nomenclature is uniformly lowercase, and the input is relatively convenient

#towards-data-science #technology #python #python3 #programming

Why Does Python Recommend the Snake-Case Nomenclature?
21.00 GEEK