Variable Scope in Python: Local, Enclosing, Global, Built-in (LEGB) Notes in Hindi & English : वेरिएबल स्कोप: LEGB नियम (Local, Enclosing, Global, Built-in) और 20 महत्वपूर्ण MCQ प्रश्न (Rajasthan IT Exam)

Post a Comment

PGDCA, BCA, B-Tech, MCA, M-Tech, B.Sc computer science राजस्थान सूचना सहायक व कंप्यूटर शिक्षक विशेष नोट्स: इस अध्याय में हम Variable Scope in Python: Local, Enclosing, Global, Built-in (LEGB) (वेरिएबल स्कोप: LEGB नियम (Local, Enclosing, Global, Built-in)) की संपूर्ण थ्योरी, मुख्य तकनीकी बिंदु, तुलनात्मक तालिका और विगत परीक्षाओं के पैटर्न पर आधारित 20 अति-महत्वपूर्ण बहुविकल्पीय प्रश्न (MCQs) विस्तृत हिंदी व अंग्रेजी व्याख्या सहित पढ़ेंगे।

Overview: Python resolves variable names at runtime using the LEGB hierarchy: Local, Enclosing, Global, and Built-in namespaces. Understanding how CPython scopes bind identifiers across functions, closures, classes, and comprehensions prevents NameError and UnboundLocalError bugs.

अध्याय सार: पायथन रनटाइम पर वेरिएबल नामों को LEGB क्रम (Local, Enclosing, Global, Built-in) के अनुसार खोजता है। फंक्शन, क्लोजर, क्लास और कॉम्प्रिहेंशन में स्कोप के नियम समझने से NameError और UnboundLocalError जैसी त्रुटियों से बचा जा सकता है।

Variable Scope in Python: Local, Enclosing, Global, Built-in (LEGB): Detailed Notes & Architecture (वेरिएबल स्कोप: LEGB नियम (Local, Enclosing, Global, Built-in))

1. Local (L) Scope and Function Execution Frames (लोकल (L) स्कोप और फंक्शन फ्रेम)

[EN] Every call to a Python function or lambda creates an isolated local namespace containing its parameters and locally assigned variables. CPython compiles local lookups into fast array-indexed LOAD_FAST bytecode instructions rather than dictionary lookups. Crucially, control-flow blocks like if, for, and while do NOT create a new local scope in Python, so variables assigned inside them persist in the enclosing function or module. If a function assigns to a name anywhere in its body without declaring it global or nonlocal, Python marks that name local for the entire function, raising UnboundLocalError if read before assignment.

[HI] पायथन में प्रत्येक फंक्शन या लैम्ब्डा कॉल अपने पैरामीटर्स और भीतर असाइन किए गए वेरिएबल्स के लिए एक अलग लोकल नेमस्पेस बनाता है। CPython लोकल वेरिएबल एक्सेस को तेज LOAD_FAST बाइटकोड निर्देश में संकलित करता है। C या Java के विपरीत, if, for और while जैसे ब्लॉक नया लोकल स्कोप नहीं बनाते, इसलिए उनके भीतर बने वेरिएबल बाहर भी उपलब्ध रहते हैं। यदि किसी फंक्शन में वेरिएबल को असाइन किया गया है, तो पूरा फंक्शन उसे लोकल मानता है और असाइनमेंट से पहले पढ़ने पर UnboundLocalError आता है।

2. Enclosing (E) Scope and Closure Cell Objects (एनक्लोजिंग (E) स्कोप और क्लोजर सेल ऑब्जेक्ट)

[EN] When a function is nested inside another function, the outer function's namespace acts as the Enclosing (non-local) scope for the inner function. Python captures referenced outer variables inside cell objects stored in the inner function's __closure__ tuple and reads them via LOAD_DEREF. This mechanism enables closures, allowing inner functions to remember outer state even after the outer function finishes executing. A classic pitfall is late binding in loops: closures capture variable bindings rather than snapshot values, so multiple lambdas created in a loop share the final loop variable value unless bound as a default argument.

[HI] जब एक फंक्शन किसी दूसरे फंक्शन के भीतर परिभाषित होता है, तो बाहरी फंक्शन का नेमस्पेस भीतरी फंक्शन के लिए Enclosing स्कोप कहलाता है। पायथन संदर्भित बाहरी चरों को सेल ऑब्जेक्ट्स में सहेजता है जो भीतरी फंक्शन के __closure__ टपल में रहते हैं और LOAD_DEREF से पढ़े जाते हैं। इसी मैकेनिज्म से क्लोजर बनते हैं जो बाहरी फंक्शन के समाप्त होने के बाद भी उसका डेटा याद रखते हैं। लूप के भीतर बने लैम्ब्डा में लेट-बाइंडिंग के कारण सभी फंक्शन लूप का अंतिम मान साझा करते हैं, जिसे डिफ़ॉल्ट आर्ग्यूमेंट देकर रोका जाता है।

3. Global (G) and Built-in (B) Namespaces (ग्लोबल (G) और बिल्ट-इन (B) नेमस्पेस)

[EN] The Global scope corresponds to a module's top-level dictionary, accessible programmatically via globals(), and is looked up using LOAD_GLOBAL when a name is absent in L and E. Each Python module maintains its own independent global namespace rather than sharing one universal global pool across files. If a name is missing from Local, Enclosing, and Global scopes, Python finally checks the Built-in namespace (the builtins module containing len, int, print, and Exception). Assigning a local or global variable named list or sum shadows the built-in identifier without error until you attempt to call the shadowed built-in, which triggers TypeError.

[HI] ग्लोबल स्कोप किसी मॉड्यूल के टॉप-लेवल डिक्शनरी से जुड़ा होता है जिसे globals() से देखा जा सकता है; L और E में न मिलने पर यहीं खोज होती है। प्रत्येक पायथन मॉड्यूल का अपना स्वतंत्र ग्लोबल नेमस्पेस होता है। यदि नाम L, E और G तीनों में न मिले, तो पायथन अंत में Built-in नेमस्पेस (builtins मॉड्यूल जैसे len, int, print) की जांच करता है और न मिलने पर NameError देता है। यदि यूजर list या sum नाम का वेरिएबल बना दे, तो वह बिल्ट-इन नाम को शैडो कर देता है और उसे फंक्शन की तरह कॉल करने पर TypeError आता है।

4. Class Namespace & Python 3 Comprehension Nuances (क्लास नेमस्पेस और पायथन 3 कॉम्प्रिहेंशन के विशेष नियम)

[EN] Although a class body defines its own namespace dictionary during class creation, it is NOT an enclosing scope for methods written inside that class. Consequently, a method must reference class attributes via self.attr or ClassName.attr; bare names inside methods skip the class scope and jump straight to module Global. In Python 3, list, set, and dictionary comprehensions as well as generator expressions execute inside their own implicit local scope frame. Unlike Python 2, loop variables inside [x for x in range(5)] never leak into or overwrite variables in the surrounding scope.

[HI] यद्यपि क्लास बॉडी निर्माण के समय अपना अलग नेमस्पेस बनाती है, लेकिन वह क्लास के भीतर लिखे गए मेथड्स के लिए Enclosing स्कोप नहीं होती। इसलिए मेथड्स के अंदर बिना self. या ClassName. के लिखा गया वेरिएबल क्लास स्कोप को छोड़कर सीधे ग्लोबल स्कोप में खोजा जाता है। पायथन 3 में लिस्ट, सेट, डिक्शनरी कॉम्प्रिहेंशन और जनरेटर एक्सप्रेशन अपना स्वयं का अलग लोकल स्कोप बनाते हैं। पायथन 2 के विपरीत, [x for x in range(5)] का लूप वेरिएबल बाहरी स्कोप में लीक नहीं होता और न ही पुराने मान को बदलता है।

Syntax, Formula & Technical Example (Variable Scope in Python: Local, Enclosing, Global, Built-in (LEGB))

x = "global_x"
def outer():
    x = "enclosing_x"
    def inner():
        y = "local_y"
        # L -> E -> G -> B (len from builtins)
        return f"{y} | {x} | len={len(y)}"
    return inner()
print(outer(), "| top:", x)

Variable Scope in Python: Local, Enclosing, Global, Built-in (LEGB) Quick Reference & Comparison Table

Scope LevelLookup Order & MechanismKey Exam Fact
Local (L)1st: Function frame (LOAD_FAST)Created by def/lambda/comprehensions; NOT by if/for blocks
Enclosing (E)2nd: Outer def cells (LOAD_DEREF)Used in nested closures via __closure__ cell objects
Global (G)3rd: Module __dict__ (LOAD_GLOBAL)Per-module top-level scope; inspected with globals()
Built-in (B)4th: builtins module namespaceHolds len, int, NameError if absent in all 4 levels

Variable Scope in Python: Local, Enclosing, Global, Built-in (LEGB) Top 20 Bilingual MCQs with Answers

Q1. In Python's LEGB rule, what is the exact order in which variable names are resolved?

(पायथन के LEGB नियम में वेरिएबल नाम किस सटीक क्रम में खोजे जाते हैं?)

(A) Local -> Global -> Enclosing -> Built-in

(B) Built-in -> Global -> Enclosing -> Local

(C) Local -> Enclosing -> Global -> Built-in

(D) Global -> Local -> Enclosing -> Built-in

Correct Answer: (C)

[EN] Python always searches the innermost Local scope first, then Enclosing functions, then module Global, and finally Built-in.

[HI] पायथन सबसे पहले सबसे भीतरी Local स्कोप, फिर Enclosing, फिर Global और अंत में Built-in स्कोप की जांच करता है।

Q2. Which Python construct does NOT create a new variable scope?

(निम्न में से कौन-सा पायथन कंस्ट्रक्ट नया वेरिएबल स्कोप नहीं बनाता है?)

(A) if / for / while code blocks

(B) def function definition

(C) lambda expression

(D) List comprehension in Python 3

Correct Answer: (A)

[EN] Control-flow blocks such as if, for, and while share the surrounding function or module scope in Python.

[HI] पायथन में if, for और while ब्लॉक नया स्कोप नहीं बनाते बल्कि आसपास के फंक्शन या मॉड्यूल के स्कोप को साझा करते हैं।

Q3. What exception is raised if a variable name cannot be found in Local, Enclosing, Global, or Built-in scopes?

(यदि कोई वेरिएबल नाम L, E, G या B किसी भी स्कोप में नहीं मिलता, तो कौन-सा एक्सेप्शन आता है?)

(A) NameError

(B) UnboundLocalError

(C) AttributeError

(D) KeyError

Correct Answer: (A)

[EN] Failing to resolve an identifier across all four LEGB layers raises a NameError.

[HI] LEGB के चारों स्तरों में वेरिएबल न मिलने पर पायथन NameError उत्पन्न करता है।

Q4. Which exception occurs when a function references a variable locally before assigning to it, even though a global variable with the same name exists?

(जब किसी फंक्शन में ग्लोबल वेरिएबल के समान नाम वाले वेरिएबल को असाइनमेंट से पहले पढ़ा जाता है, तो कौन-सा एरर आता है?)

(A) ValueError

(B) NameError

(C) ReferenceError

(D) UnboundLocalError

Correct Answer: (D)

[EN] Any assignment inside a function binds the name as local for the whole function body, causing UnboundLocalError if read earlier.

[HI] फंक्शन के भीतर असाइनमेंट होने पर नाम पूरे फंक्शन के लिए लोकल माना जाता है, जिससे पहले पढ़ने पर UnboundLocalError आता है।

Q5. Which CPython bytecode instruction is used to load a normal local variable inside a function?

(फंक्शन के भीतर सामान्य लोकल वेरिएबल को लोड करने के लिए CPython किस बाइटकोड निर्देश का उपयोग करता है?)

(A) LOAD_FAST

(B) LOAD_DEREF

(C) LOAD_CONST

(D) LOAD_GLOBAL

Correct Answer: (A)

[EN] CPython optimizes local variables inside functions into fixed-slot arrays accessed via LOAD_FAST.

[HI] CPython फंक्शन के भीतर लोकल वेरिएबल्स को तेज एक्सेस के लिए LOAD_FAST निर्देश का उपयोग करता है।

Q6. Where are Enclosing scope variables referenced by an inner closure stored on the inner function object?

(इनर क्लोजर द्वारा उपयोग किए जाने वाले Enclosing स्कोप के वेरिएबल इनर फंक्शन ऑब्जेक्ट पर कहां संग्रहीत होते हैं?)

(A) In cell objects inside __closure__

(B) Inside the class __mro__ tuple

(C) In the module's sys.argv list

(D) Inside __builtins__ dictionary

Correct Answer: (A)

[EN] Nested functions capture free variables from enclosing scopes as cell objects referenced by func.__closure__.

[HI] नेस्टेड फंक्शन बाहरी स्कोप के वेरिएबल्स को सेल ऑब्जेक्ट्स के रूप में __closure__ टपल में सहेजते हैं।

Q7. Which built-in module contains standard names such as len, print, int, and Exception?

(len, print, int और Exception जैसे मानक नाम किस बिल्ट-इन मॉड्यूल में रहते हैं?)

(A) builtins

(B) sys

(C) __main__

(D) os

Correct Answer: (A)

[EN] Python's Built-in (B) scope corresponds directly to the builtins module namespace.

[HI] पायथन का Built-in (B) स्कोप सीधे builtins मॉड्यूल के नेमस्पेस से संबंधित होता है।

Q8. What happens if you assign `list = [1, 2, 3]` globally and then call `list('abc')`?

(यदि आप ग्लोबल रूप से `list = [1, 2, 3]` लिखें और फिर `list('abc')` कॉल करें तो क्या होगा?)

(A) SyntaxError is raised at compile time

(B) It returns ['a', 'b', 'c'] normally

(C) TypeError is raised because the global variable shadows the built-in list type

(D) NameError is raised because built-ins are deleted

Correct Answer: (C)

[EN] Global scope (G) precedes Built-in scope (B), so calling list('abc') tries to invoke the list object [1, 2, 3], raising TypeError.

[HI] Global स्कोप Built-in से पहले आता है, इसलिए list('abc') एक लिस्ट ऑब्जेक्ट को कॉल करने का प्रयास करता है और TypeError देता है।

Q9. In Python 3, what happens to the loop variable `i` after executing `[i*2 for i in range(4)]`?

(पायथन 3 में `[i*2 for i in range(4)]` चलाने के बाद लूप वेरिएबल `i` का क्या होता है?)

(A) It leaks into the surrounding scope with value 4

(B) It stays isolated inside the comprehension scope and does not exist outside

(C) It leaks into the surrounding scope with value 3

(D) It automatically becomes a global variable

Correct Answer: (B)

[EN] Since Python 3.0, list comprehensions have their own dedicated local frame so loop variables never leak outward.

[HI] पायथन 3.0 से लिस्ट कॉम्प्रिहेंशन का अपना अलग लोकल फ्रेम होता है, इसलिए वेरिएबल बाहर लीक नहीं होता।

Q10. In a Python class, does a method's LEGB lookup search the enclosing class body scope for bare variable names?

(क्या पायथन क्लास के मेथड के भीतर बिना self के लिखा गया वेरिएबल क्लास बॉडी के स्कोप में खोजा जाता है?)

(A) Yes, but only for private attributes starting with _

(B) No, class namespaces are skipped in LEGB lookup for methods

(C) Yes, class body always acts as Enclosing (E) scope

(D) Yes, only in static methods

Correct Answer: (B)

[EN] A class definition creates a temporary namespace for attributes, not an enclosing scope for its methods; methods look up Global after Local.

[HI] क्लास नेमस्पेस मेथड्स के लिए Enclosing स्कोप नहीं बनता; मेथड्स के भीतर बिना self के नाम सीधे ग्लोबल स्कोप में जाते हैं।

Q11. Which built-in function returns a dictionary representing the current module's global symbol table?

(कौन-सा बिल्ट-इन फंक्शन वर्तमान मॉड्यूल की ग्लोबल सिंबल टेबल की डिक्शनरी लौटाता है?)

(A) globals()

(B) vars(builtins)

(C) id()

(D) dir()

Correct Answer: (A)

[EN] globals() returns the live dictionary of the current module namespace where global names are stored.

[HI] globals() वर्तमान मॉड्यूल के ग्लोबल नेमस्पेस की डिक्शनरी लौटाता है।

Q12. What is the output of: x = 10 def f(): x = 20 return x print(f(), x)

(कोड का आउटपुट क्या होगा: x = 10 def f(): x = 20 return x print(f(), x))

(A) 20 20

(B) 20 10

(C) 10 10

(D) UnboundLocalError

Correct Answer: (B)

[EN] Assigning x = 20 inside f creates a separate local variable x, leaving the global x equal to 10.

[HI] f के अंदर x = 20 लिखने से नया लोकल x बनता है और ग्लोबल x का मान 10 ही बना रहता है।

Q13. What is the output of: x = 5 def outer(): x = 15 def inner(): return x return inner() print(outer())

(इस कोड का आउटपुट क्या होगा: x = 5 def outer(): x = 15 def inner(): return x return inner() print(outer()))

(A) None

(B) 5

(C) 15

(D) NameError

Correct Answer: (C)

[EN] inner() has no local x, so LEGB checks Enclosing scope (outer) first and finds x = 15 before reaching Global x = 5.

[HI] inner() में लोकल x नहीं है, इसलिए LEGB पहले Enclosing स्कोप (outer) में x = 15 पाता है।

Q14. If a `for i in range(3): pass` loop runs inside a function `test()`, is `i` still accessible after the loop inside `test()`?

(यदि किसी फंक्शन `test()` के अंदर `for i in range(3): pass` चले, तो क्या लूप के बाद `i` फंक्शन के अंदर उपलब्ध रहेगा?)

(A) Yes, i becomes None after the loop

(B) Yes, i remains in test()'s local scope with value 2

(C) Only if i was declared before the loop

(D) No, NameError occurs because for-loops have block scope

Correct Answer: (B)

[EN] For-loops do not create block scopes in Python, so i remains bound to its final value 2 in test()'s local frame.

[HI] पायथन में for लूप नया ब्लॉक स्कोप नहीं बनाता, इसलिए लूप समाप्त होने पर भी i का मान 2 फंक्शन में उपलब्ध रहता है।

Q15. What happens when you create `[lambda: i for i in range(3)]` and call the first lambda?

(यदि `[lambda: i for i in range(3)]` बनाया जाए और पहले लैम्ब्डा को कॉल किया जाए तो क्या लौटेगा?)

(A) 0, because each lambda snapshots i at creation

(B) NameError, because i is destroyed after the comprehension

(C) 2, because closures perform late binding on the enclosing comprehension variable i

(D) 3, because range ends at 3

Correct Answer: (C)

[EN] Closures look up enclosing variable i at call time (late binding), when the loop has ended with i = 2.

[HI] क्लोजर कॉल के समय i का मान देखता है (लेट बाइंडिंग), जब लूप 2 पर समाप्त हो चुका होता है।

Q16. Which of the following statements is NOT true about Python variable scopes?

(पायथन वेरिएबल स्कोप के बारे में निम्न में से कौन-सा कथन सत्य नहीं है?)

(A) Every module shares a single unified global namespace across the entire Python process

(B) Shadowing a built-in name does not delete it from the builtins module

(C) Local scope is checked before Enclosing scope in LEGB

(D) if-else statements do not create their own separate scope

Correct Answer: (A)

[EN] Global scope in Python is per-module, not shared globally across all imported modules unless explicitly imported or referenced.

[HI] पायथन में ग्लोबल स्कोप प्रति-मॉड्यूल होता है, पूरे प्रोग्राम में एक साझा ग्लोबल टेबल नहीं होती।

Q17. Within Variable Scope in Python: Local, Enclosing, Global, Built-in (LEGB), which scope level directly maps to: "1st: Function frame (LOAD_FAST)"?

(Variable Scope in Python: Local, Enclosing, Global, Built-in (LEGB) में कौन सा Scope Level सीधे "1st: Function frame (LOAD_FAST)" से संबंधित है?)

(A) Global (G)

(B) Built-in (B)

(C) Enclosing (E)

(D) Local (L)

Correct Answer: (D)

[EN] In Variable Scope in Python: Local, Enclosing, Global, Built-in (LEGB), 'Local (L)' handles '1st: Function frame (LOAD_FAST)' (Created by def/lambda/comprehensions; NOT by if/for blocks).

[HI] Variable Scope in Python: Local, Enclosing, Global, Built-in (LEGB) में 'Local (L)' का कार्य/विवरण '1st: Function frame (LOAD_FAST)' (Created by def/lambda/comprehensions; NOT by if/for blocks) है।

Q18. Which option accurately describes 'Enclosing (E)' in Variable Scope in Python: Local, Enclosing, Global, Built-in (LEGB)?

(Variable Scope in Python: Local, Enclosing, Global, Built-in (LEGB) के संदर्भ में 'Enclosing (E)' की सही विशेषता कौन सी है?)

(A) 1st: Function frame (LOAD_FAST)

(B) 3rd: Module __dict__ (LOAD_GLOBAL)

(C) 4th: builtins module namespace

(D) 2nd: Outer def cells (LOAD_DEREF)

Correct Answer: (D)

[EN] 'Enclosing (E)' provides '2nd: Outer def cells (LOAD_DEREF)' — key point: Used in nested closures via __closure__ cell objects.

[HI] 'Enclosing (E)' का मुख्य विवरण '2nd: Outer def cells (LOAD_DEREF)' है (Used in nested closures via __closure__ cell objects)।

Q19. In Variable Scope in Python: Local, Enclosing, Global, Built-in (LEGB), identify the correct parameter for the specification: "3rd: Module __dict__ (LOAD_GLOBAL)".

(Variable Scope in Python: Local, Enclosing, Global, Built-in (LEGB) में "3rd: Module __dict__ (LOAD_GLOBAL)" विवरण किस विकल्प के लिए सही है?)

(A) Global (G)

(B) Built-in (B)

(C) Enclosing (E)

(D) Local (L)

Correct Answer: (A)

[EN] 'Global (G)' corresponds to '3rd: Module __dict__ (LOAD_GLOBAL)' (Per-module top-level scope; inspected with globals()).

[HI] 'Global (G)' का संबंध '3rd: Module __dict__ (LOAD_GLOBAL)' (Per-module top-level scope; inspected with globals()) से है।

Q20. Considering Variable Scope in Python: Local, Enclosing, Global, Built-in (LEGB), what key behavior defines 'Built-in (B)'?

(Variable Scope in Python: Local, Enclosing, Global, Built-in (LEGB) में 'Built-in (B)' की मुख्य भूमिका या मान क्या है?)

(A) 3rd: Module __dict__ (LOAD_GLOBAL)

(B) 1st: Function frame (LOAD_FAST)

(C) 4th: builtins module namespace

(D) 2nd: Outer def cells (LOAD_DEREF)

Correct Answer: (C)

[EN] 'Built-in (B)' represents '4th: builtins module namespace' (Holds len, int, NameError if absent in all 4 levels).

[HI] 'Built-in (B)' का अर्थ/मान '4th: builtins module namespace' है (Holds len, int, NameError if absent in all 4 levels)।

Variable Scope in Python: Local, Enclosing, Global, Built-in (LEGB) — Exam FAQs

Q1: Why does Python raise UnboundLocalError even when a global variable with the same name exists?

एक ही नाम का ग्लोबल वेरिएबल मौजूद होने पर भी पायथन UnboundLocalError क्यों देता है?

[EN] Python decides variable scope at compile time across the entire function body. If an assignment like `x = x + 1` appears anywhere inside the function without `global x`, `x` is compiled as a local variable everywhere in that function, so reading `x` before its local assignment fails.

[HI] पायथन संकलन (कम्पाइल) समय पर ही पूरे फंक्शन में वेरिएबल का स्कोप तय कर लेता है। यदि फंक्शन के भीतर कहीं भी `x = ...` जैसा असाइनमेंट बिना `global x` के है, तो पूरा फंक्शन `x` को लोकल मानता है और पहले पढ़ने पर UnboundLocalError आ जाता है।

Q2: Why can't a method access a class attribute directly without `self.` or the class name?

क्लास के भीतर कोई मेथड बिना `self.` या क्लास के नाम के क्लास एट्रिब्यूट को सीधे क्यों नहीं पढ़ पाता?

[EN] According to Python's scoping rules, a class body's namespace is only active while building the class dictionary and is skipped during LEGB lookup inside methods. Therefore, bare names inside a method jump from Local straight to Enclosing functions or module Global.

[HI] पायथन के नियम के अनुसार क्लास बॉडी का नेमस्पेस मेथड्स के लिए Enclosing स्कोप नहीं बनता। इसलिए मेथड के भीतर बिना `self.` के लिखा नाम लोकल के बाद सीधे ग्लोबल स्कोप में खोजा जाता है।

Q3: How can you restore a built-in function if you accidentally shadowed it with a global variable?

यदि गलती से कोई बिल्ट-इन फंक्शन ग्लोबल वेरिएबल से शैडो हो जाए, तो उसे वापस कैसे प्राप्त करें?

[EN] You can delete the shadowing global name using `del len` (or whichever name was overwritten), or explicitly import and access the original function via `import builtins; builtins.len(...)`.

[HI] आप `del len` द्वारा उस ग्लोबल वेरिएबल को हटा सकते हैं या `import builtins; builtins.len(...)` द्वारा मूल बिल्ट-इन फंक्शन का उपयोग कर सकते हैं।

Related Posts

  • Loading related posts...

Post a Comment

Search Topic Notes & 20 MCQs (Hindi / English)