-1

Any tips on how I should properly be naming python variables? Like any correct forms or for clean code.

Like for instance

myNum = 1

or

mynum = 1

or

my_num = 1
pbedol
  • 13
  • 1
  • 2
  • As long as you can look at a variable and know what it is for, it probably doesn't matter. But if someone else will be looking at your code, you might want to make them more specific. [Python naming conventions](https://stackoverflow.com/questions/159720/what-is-the-naming-convention-in-python-for-variable-and-function-names) – Merp Jan 25 '21 at 23:57
  • 3
    Python has an [official style guide](https://www.python.org/dev/peps/pep-0008/), but it isn't mandatory. This question is opinion-based and therefore off-topic. – ChrisGPT was on strike Jan 26 '21 at 00:00
  • Dont use abstract naming , make your code human readable. – Avatazjoe Jan 26 '21 at 00:01

2 Answers2

1

PEP 8 recommends my_num. @Merp's comment is correct though. Be clear and consistent with whatever convention you choose.

AnkurSaxena
  • 825
  • 7
  • 11
0

Well, traditionally developers follow the 'camelCase' variable naming proceedure in most languages, which is basically shown in your 1st code snippet. However, there are exceptions in the wide range of programming languages out there in terms of norms that manifest themselves over time. In Python, most developers tend to use the variable naming shown in your 3rd code snippet, separating each word with an underscore.

Bialomazur
  • 1,122
  • 2
  • 7
  • 18