logo
logo
Sign in

Identifiers in Python

avatar
skill technical
Identifiers in Python

Identifiers in Python

 



Python Identifier is the name we give to distinguish a variable, function, class, module or other object. That means whenever we want to give an reality a name, that’s called identifier.

 

Occasionally variable and identifier are again and again misinterpreted as same but they're not. Well for clearness, let’s see what's a variable?

 

What's a Variable in Python?

 

A variable, as the name indicates is individuality whose value is flexible over time. In fact a variable is a memory position where a value can be kept. Latterly we can get back the value to use. But for doing it we need to give a surname to that memory site so that we can appertain to it. That’s identifier, the cognomen.

 

 

 

Rules

 

1-The identifiers in python programming can be framed as a fusion of both uppercase (A to Z), lowercase (a to z) and number values (1 to 9). In extension to the uppercase, lowercase and number values, symbols like underscores can also be applied.

 

2-A number value can nothing be used for defining the launch of the identifier value. Any case where a number is prefixed to the variable name is called to be an invalidly declared python identifier.

 

3-Non among the predefined keywords can be used as an identifier in python. The predefined keywords are reserved words in python. Keywords being the silent words for a python programming language, it means like these words can not be used in any other user cases rather of their single use.

 

4-Identifiers can not hold any kind of special characters other than, in its accomplishment. Some among the special characters which aren't decent for a identifier affirmation are as listed”!,@,#,$,,, &, *, (,),

, “.

 

 

 

Best Practices

 

For private variables, you can jump their names with an underscore.

 

Escape underscore as the first and ultimate character in the identifier name. It’s applied by python built-in types.

 

Still, also it means that the identifier is a language- defined special name, If the identifier starts and ends with two underscores. So you should escape having two underscores at the launch and the end of the identifier name.

 

Keep identifier names expressive to clarify their intention. For illustration ,phone _number, is _uppercase, etc.

 

collect
0
avatar
skill technical
guide
Zupyak is the world’s largest content marketing community, with over 400 000 members and 3 million articles. Explore and get your content discovered.
Read more