Python Identifiers
Python identifier is a name used to identify a variable,function,class,module or other objects.
There are some rules/conventions about naming identifiers.
- An identifier can start with the letter “A-Z” or “a-z”.
- An identifier can start with the “_”followed by any digit or letter.
- An identifier can start with the any letter followed by any digit.
- An identifier can’t start with a digit
- An identifier can’t use functional characters such as @,%,!
Note: Python is case sensitive language. So “name” and “Name” are 2 different identifiers.
Some conventions about naming identifiers.
- Class names start with uppercase letters and all other identifiers with a lowercase letter Ex: Student stu1=new Student( ) Shape s1=new Shape( )
- Starting an identifier with single leading underscore indicate by convention that the identifier is need to be private Ex: _accountno
- Starting an identifier with 2 leading underscores indicate a strongly private identifire Ex:_ _password _ _pinnumber
No comments:
Post a Comment