Identifiers in Python

Identifier is used to identify variables, classes, objects, functions, etc. To simply put it is a name by which anything can be identified in Python.

Rules for identifiers in Python:
  • First letter must not be a number
  • can start with underscore or alphabet
  • identifier can be a mix of alphabets, numbers, underscore
  • Special characters cannot be used
  •  maximum length of identifier is 79 characters
Tips to use identifiers:
  • use a proper name which represents the functionality
  • As Python is case sensitive, be careful while using the identifiers
  • While starting an identifier with _ (underscore) is allowed, readability wise this doesn't give a good feel
  • When the identifier is long, try to separate with _ (underscore) which improves readability
Example usage of identifiers:

num
Num
_num
num1

Post a Comment

0 Comments