Python Identifiers

A name in python program is called as Identifier. The name may be a variable name, or a function name, or a class name etc.




Example:

x=10

here x is an identifier

def f1():

pass

Here the function name f1 is an identifier

class Simple(Exception): # class name Simple is identifier


Rules & Regulations to define Python Identifiers:


  1. The following symbols are allowed in python identifier;
    Alphabet symobols(both upper case and lower case)
    A-Z
    a-z
    digits(0-9)
    underscore(_)

    ` Example:number(valid identifier)
          Number#(invalid identifier)

  2. Identifier should not start with digits.
    Sum13(valid identifier)
    123sum(invalid identifier)

  3. 123sum(invalid identifier)
    sum=100
    SUM=120
    Here both sum and SUM are valid identifier.

  4. Keywords never consider as identifier

    Sum=0(valid)
    if=100(invalid identifier)

  5. There is no length limit of an identifier.
    Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=10
    Here it is a valid identifier, but it is not recommended, because the readability of the code is reduced.

Note:

The underscore symbol(_) starts with any identifier, then that is private.

If two underscore symbol(__) starts with any identifier then it is strongly private.


About the Author



Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.

We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc






 PreviousNext