❮ Previous Next ❯

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.



python identifiers

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.


❮ Previous Next ❯

Follow Us




  Tutorials

Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Bhubaneswar-751013
      Email: info@silantechnology.com
      Phone: 0674-2361252
address
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved