What are valid python identifiers?

PythonServer Side ProgrammingProgramming

An identifier in a Python program is name given to various elements in it, such as keyword, variable, function, class, module, package etc. An identifier should start with either an alphabet (lower or upper case) or underscore (_). More than one alpha-numeric characters or underscore may follow.

Keywords are predefined. They are in lowercase. They can not be used for any other purpose.

By convention, name of class starts with uppercase alphabet. Whereas others start with lowercase alphabet.

Single underscore in the beginning of a variable name is used to indicate a private variable.

Two underscores in beginning indicate that the variable is strongly private.

Two leading and trailing underscores are used in language itself for special purpose. For example (e.g. __add__, __init__)

Published on 20-Dec-2017 09:06:44