Identifiers

In a Python program or any other programming language, it is common to use programming elements such as variables, keywords, functions, classes, modules and packages.
These elements have names which are predefined in the language, or can be used by the programmer at the time of writing code.
These names are called Identifiers.

Examples :

variables    -----     _bookname, num1
keywords   -----      if, while, yield
functions    -----      print(), int(), len()
classes        -----      Complex, Exception
modules     ------     Calender, random
packages    -----       Pillow, tkinter


An identifier can only start with an alphabet that may be 

abcdefghijklmnopqrstuvwxyz                                                                 in small
ABCDEFGHIJKLMNOPQRSTUVWXYZ                                            or in CAPS.

It can also start with an '_'  ( underscore).
Remember, the rest of the characters are not allowed.

5number
*house
$value
)book

The above identifiers are incorrect.  The correct syntax could be 

book3
house_no

This means we cannot use any special character (@,#,%,$,&,*) or number (0123456789) in the beginning of the identifier.

A keyword may be written in small letters.

    -    if, while

Class' name starts with Capital Letter

   -     Complex, Exception

Private variables are declared by adding a single underscore in the beginning.

   -     _aadharnum, _accountnum

Adding 2 underscores indicated variable is strongly protected.

   -     __mobilenum, __loginid

Two leading and trailing underscores are used in the language for special purpose.

   -     __add__, __int__



Thats it for IDENTIFIERS.

Comments

Popular posts from this blog

Comparing Python 2.x and Python 3.x

Syntax of Python

IDLE