हिंदी

Explain LEGB rule.

Advertisements
Advertisements

प्रश्न

Explain LEGB rule.

स्पष्ट कीजिए
Advertisements

उत्तर

The LEGB rule specifies the order in which Python searches for a name:

  1. L - Local: Searches inside the current function.
  2. E - Enclosing: Searches in enclosing functions, from inner to outer.
  3. G - Global: Searches in the global namespace of the module.
  4. B - Built-in: Searches in Python's built-in namespace.

Thus, Python uses the first matching name found in the order: Local → Enclosing → Global → Built-in.

shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 3: Classes in Python - EXERCISE [पृष्ठ ६२]

APPEARS IN

सीबीएसई Computer Science with Python [English] Class 12
अध्याय 3 Classes in Python
EXERCISE | Q 4. | पृष्ठ ६२
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×