Identifiers :-
Python में किसी भी Variable, Function, Class, Module, Object, Package आदि को पहचान (Identify) देने के लिए जो नाम (Name) दिया जाता है, उसे Identifier (आइडेंटिफ़ायर) कहते हैं।
सरल शब्दों में,
Python Program में किसी भी Variable, Function, Class या अन्य Program Element का नाम ही Identifier कहलाता है।
जब Python Program Execute होता है, तब Python इन्हीं Identifiers की सहायता से यह पहचानता है कि किस Variable में कौन-सी Value है, किस Function को Call करना है और किस Class का उपयोग करना है।
यदि Program में Identifiers न हों, तो Python अलग-अलग Data और Program Elements को पहचान नहीं पाएगा।
English
An Identifier is the name given to a Variable, Function, Class, Module, Object, Package, or any other program element in Python.
In simple words,
The name of any program element in Python is called an Identifier.
Python uses identifiers to recognize and access variables, functions, classes, and other program elements while executing the program.
Without identifiers, Python cannot identify different program elements.
Identifier Naming Rules (आइडेंटिफ़ायर नामकरण के नियम) :-
Python में Identifier का नाम रखते समय कुछ नियमों का पालन करना आवश्यक होता है। यदि इन नियमों का पालन नहीं किया जाता है, तो Python Program में Error आ सकती है।
Rule 1: Identifier must start with a Letter or Underscore (_) / Identifier की शुरुआत Letter (अक्षर) या Underscore (_) से होनी चाहिए।
Identifier का पहला Character अंग्रेज़ी का अक्षर (A–Z, a–z) या Underscore (_) होना चाहिए। यदि पहला Character Number होगा, तो Python उसे स्वीकार नहीं करेगा और Error देगा।
English:
An Identifier must begin with an English letter (A–Z, a–z) or an underscore (_). It cannot start with a digit.
Valid Examples:
Invalid Examples:
Rule 2: Identifier cannot start with a Number / Identifier की शुरुआत Number (अंक) से नहीं हो सकती।
Identifier में Number का उपयोग किया जा सकता है, लेकिन शुरुआत Number से नहीं हो सकती।
English:
Numbers can be used in an Identifier, but they cannot be the first character.
Valid Examples:
Invalid Examples:
Rule 3: Only Letters, Digits and Underscore (_) are allowed / Identifier में केवल Letters, Digits और Underscore (_) का उपयोग किया जा सकता है।
Identifier में केवल अंग्रेज़ी के अक्षर (A–Z, a–z), अंक (0–9) तथा Underscore (_) का उपयोग किया जा सकता है।
English:
An Identifier may contain only letters, digits, and an underscore (_).
Valid Examples:
Invalid Examples:
Rule 4: Spaces are not allowed / Identifier में Space (खाली स्थान) का उपयोग नहीं किया जा सकता।
Identifier में Space नहीं होना चाहिए। यदि नाम में एक से अधिक शब्द हों, तो उनके बीच Underscore (_) का उपयोग करें।
English:
Spaces are not allowed in Identifiers. Use an underscore (_) to separate words.
Valid Examples:
Invalid Examples:
Rule 5: Special Characters are not allowed / Identifier में Special Characters का उपयोग नहीं किया जा सकता।
Identifier में @, #, $, %, &, *, !, +, -, /, . आदि Special Characters का उपयोग नहीं किया जा सकता।
English:
Special characters such as @, #, $, %, &, *, !, +, -, /, and . are not allowed in Identifiers.
Valid Examples:
Invalid Examples:
Rule 6: Python Keywords cannot be used as Identifiers / Python Keywords को Identifier के रूप में उपयोग नहीं किया जा सकता।
Python के Reserved Keywords का अपना विशेष अर्थ होता है, इसलिए इन्हें Variable, Function या Class का नाम नहीं बनाया जा सकता।
English:
Python Keywords are reserved words with predefined meanings. They cannot be used as Identifiers.
Examples of Keywords:
Valid Example:
Invalid Example:
Rule 7: Python is Case Sensitive / Python Case Sensitive भाषा है।
Python में बड़े (Capital) और छोटे (Small) अक्षरों को अलग माना जाता है। इसलिए एक ही शब्द के अलग-अलग Case अलग-अलग Identifier माने जाते हैं।
English:
Python is case sensitive. Uppercase and lowercase letters are treated differently.
Examples:
ये तीनों अलग-अलग Identifiers हैं।
Rule 8: Identifier can be of any Length / Identifier की लंबाई (Length) की कोई निश्चित सीमा नहीं है।
Python में Identifier छोटा या बड़ा हो सकता है। लेकिन हमेशा ऐसा नाम रखें जो पढ़ने और समझने में आसान हो।
English:
An Identifier can be short or long. However, meaningful and readable names are recommended.
Examples:
Rule 9: Use Meaningful Names / हमेशा अर्थपूर्ण (Meaningful) नाम का उपयोग करें।
Identifier ऐसा होना चाहिए जिससे उसका उद्देश्य आसानी से समझ में आ जाए।
English:
Choose meaningful names so that the purpose of the Identifier is easy to understand.
Good Examples:
Poor Examples:
