-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
3
  • 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 Commented Jan 25, 2021 at 23:57
  • 3
    Python has an official style guide, but it isn't mandatory. This question is opinion-based and therefore off-topic. Commented Jan 26, 2021 at 0:00
  • Dont use abstract naming , make your code human readable. Commented Jan 26, 2021 at 0:01

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.