paint-brush
Short Guide to Best Practices When Naming Variables in Python by@aswinbarath
523 reads
523 reads

Short Guide to Best Practices When Naming Variables in Python

by Aswin BarathJanuary 5th, 2021
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Short Guide to Best Practices When Naming Variables in Python is published at //dev.to/aswin2001barath/variables-in-Python-12d3. Python is case sensitive, which means variables like hello and Hello are completely different in python. Do not use special characters like!@,#,$%,%% and/# in a variable name, because you will get the same error message: "./program.py", line (x), in < module>

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - Short Guide to Best Practices When Naming Variables in Python
Aswin Barath HackerNoon profile picture

Variables in programming are something like containers storing some specific things.

Variables are a way we store store data on computer. This is how we create variables in python:
# Syntax:
variable_name = "data"
But, there’s a catch here, you cannot have some crazy names as variable names in python.

There are some best practices in python being followed by the python community when it comes to naming your variables.

Dos

  • Variable names can contain letters, numbers, underscore
  • Always start with lowercase letter or an underscore
  • snake_case Use lowercase letters and underscores for spaces.

Don'ts

  • Do not use reserved keywords of python as variable names, because this is what python will tell you:
... Traceback (most recent call last): File "./program.py", line (x), in <module> ...
  • Do not use special characters like !,@,#,$,%,^,&,* in a variable name, because you will get the same error message:
... Traceback (most recent call last): File "./program.py", line (x), in <module> ...

Note

Keep in mind that python is case sensitive, which means the variables like hello and Hello are completely different in python.

Also published at

바카라사이트 바카라사이트 온라인바카라