Advertisements
Advertisements
प्रश्न
Explain LEGB rule.
स्पष्ट करा
Advertisements
उत्तर
The LEGB rule specifies the order in which Python searches for a name:
- L - Local: Searches inside the current function.
- E - Enclosing: Searches in enclosing functions, from inner to outer.
- G - Global: Searches in the global namespace of the module.
- 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
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
