PGDCA, BCA, B-Tech, MCA, M-Tech, B.Sc computer science राजस्थान सूचना सहायक व कंप्यूटर शिक्षक विशेष नोट्स: इस अध्याय में हम Default Parameter Values and Mutable Default Argument Trap (डिफ़ॉल्ट पैरामीटर्स और म्यूटेबल डिफ़ॉल्ट ट्रैप से बचाव) की संपूर्ण थ्योरी, मुख्य तकनीकी बिंदु, तुलनात्मक तालिका और विगत परीक्षाओं के पैटर्न पर आधारित 20 अति-महत्वपूर्ण बहुविकल्पीय प्रश्न (MCQs) विस्तृत हिंदी व अंग्रेजी व्याख्या सहित पढ़ेंगे।
Overview: Default parameter values make function arguments optional, but Python evaluates default expressions strictly once at function definition time rather than on each call. Consequently, using mutable objects like [] or {} as defaults creates shared state across calls—a trap safely avoided using the None sentinel pattern.
अध्याय सार: डिफ़ॉल्ट पैरामीटर मान फंक्शन आर्गुमेंट्स को वैकल्पिक बनाते हैं, लेकिन पायथन डिफ़ॉल्ट एक्सप्रेशन का मूल्यांकन हर कॉल पर करने के बजाय फंक्शन परिभाषा (def) के समय केवल एक बार करता है। इस कारण [] या {} जैसे म्यूटेबल डिफ़ॉल्ट सभी कॉल्स के बीच साझा हो जाते हैं—जिससे बचने के लिए None सेंटिनल पैटर्न उपयोग किया जाता है।
Default Parameter Values and Mutable Default Argument Trap: Detailed Notes & Architecture (डिफ़ॉल्ट पैरामीटर्स और म्यूटेबल डिफ़ॉल्ट ट्रैप से बचाव)
1. Default Parameter Syntax and Definition Ordering (डिफ़ॉल्ट पैरामीटर सिंटैक्स और परिभाषा क्रम नियम)
[EN] Assigning a fallback value in the def header (def greet(name, greeting='Hello'):) lets callers omit optional trailing arguments. Among standard positional-or-keyword parameters (before *), any parameter without a default value must precede every parameter with a default value; writing def f(a=1, b): raises SyntaxError. However, keyword-only parameters placed after * or *args can omit defaults even when earlier parameters had defaults, e.g., def f(a=1, *, b): is completely valid. Default values can also reference variables visible at definition time, and those evaluated references are captured immediately when def runs.
[HI] def हेडर में `greeting='Hello'` जैसा मान देने से कॉलर वैकल्पिक आर्गुमेंट को छोड़ सकता है। सामान्य पोजिशनल-या-कीवर्ड पैरामीटर्स (* से पहले) में बिना डिफ़ॉल्ट वाले सभी पैरामीटर डिफ़ॉल्ट मान वालों से पहले आने चाहिए; `def f(a=1, b):` लिखने पर SyntaxError आता है। हालाँकि * या *args के बाद वाले कीवर्ड-ओनली पैरामीटर्स बिना डिफ़ॉल्ट के हो सकते हैं, भले ही पहले वाले पैरामीटर्स में डिफ़ॉल्ट हों (जैसे `def f(a=1, *, b):` वैध है)। डिफ़ॉल्ट एक्सप्रेशन में परिभाषा के समय उपलब्ध वेरिएबल्स भी उपयोग किए जा सकते हैं, जिनका मान def चलते समय ही स्थिर हो जाता है।
2. Single-Evaluation Rule and __defaults__ Inspection (एकल-मूल्यांकन नियम और __defaults__ का निरीक्षण)
[EN] A foundational rule of Python's execution model is that default parameter expressions are evaluated once when def creates the function object, NOT every time the function is invoked. The resulting positional defaults are stored in a tuple on the function's __defaults__ attribute, while keyword-only defaults live in the __kwdefaults__ dictionary. This explains why a dynamic expression like def log(msg, ts=datetime.now()): freezes ts to the module import timestamp across all later calls. Because __defaults__ lives on the function object itself, its contents persist across the lifetime of that function.
[HI] पायथन के निष्पादन मॉडल का एक मूल नियम है कि डिफ़ॉल्ट पैरामीटर एक्सप्रेशन का मूल्यांकन हर कॉल पर नहीं, बल्कि केवल एक बार तब होता है जब def स्टेटमेंट फंक्शन ऑब्जेक्ट बनाता है। ये मूल्यांकित मान फंक्शन के __defaults__ टपल में (और कीवर्ड-ओनली डिफ़ॉल्ट __kwdefaults__ डिक्शनरी में) संग्रहीत रहते हैं। इसी वजह से `def log(msg, ts=datetime.now()):` लिखने पर ts का समय हमेशा मॉड्यूल लोड होने के समय पर अटक जाता है। चूँकि __defaults__ फंक्शन ऑब्जेक्ट से जुड़ा होता है, इसलिए इसके अंदर के ऑब्जेक्ट फंक्शन के पूरे जीवनकाल तक बने रहते हैं।
3. The Mutable Default Argument Trap Explained (म्यूटेबल डिफ़ॉल्ट आर्गुमेंट ट्रैप की व्याख्या)
[EN] When a mutable container such as a list [], dictionary {}, or set() is used as a default parameter (def add_item(val, items=[]):), Python creates that single list once during def and binds it into __defaults__. Every subsequent call that omits items receives a reference to that exact same list object. If the function mutates items in place (items.append(val)), each call accumulates items left behind by prior calls instead of starting with a fresh empty list. Calls where the caller explicitly passes an external list bypass the shared default, leaving the trapped default untouched until omitted again.
[HI] जब सूची [], डिक्शनरी {} या सेट set() जैसे किसी म्यूटेबल ऑब्जेक्ट को डिफ़ॉल्ट बनाया जाता है (`def add_item(val, items=[]):`), तो पायथन उसे def के समय एक ही बार बनाकर __defaults__ में रख लेता है। इसके बाद हर बार जब कॉलर `items` नहीं भेजता, तो फंक्शन को उसी पुराने एकमात्र लिस्ट ऑब्जेक्ट का रेफरेंस मिलता है। यदि फंक्शन `items.append(val)` से उसमें बदलाव करता है, तो पिछली कॉल्स का डेटा अगली कॉल में भी बना रहता है और नई खाली लिस्ट नहीं बनती। यदि कॉलर स्पष्ट रूप से कोई अलग लिस्ट पास करे तो वह अपनी लिस्ट पर काम करता है, पर आर्गुमेंट छोड़ने पर फिर वही साझा लिस्ट मिलती है।
4. The None Sentinel Fix and Legitimate Caching Uses (None सेंटिनल समाधान और वैध कैशिंग उपयोग)
[EN] The idiomatic Python fix is to use the immutable singleton None as the default value and instantiate a fresh mutable object inside the function body: if items is None: items = []. Notice the identity check `items is None` rather than `if not items:` so that an explicitly passed empty list `[]` from the caller is mutated rather than replaced by a new list! If None itself is a meaningful input value the caller might pass, define a private module-level sentinel object (`_MISSING = object()`) and test `if items is _MISSING:`. Interestingly, experts occasionally exploit the single-evaluation behavior intentionally for memoization caches (cache={}) or loop closure captures, though functools.lru_cache is cleaner.
[HI] इस समस्या का मानक पायथोनिक समाधान अपरिवर्तनीय None को डिफ़ॉल्ट रखना और बॉडी के भीतर `if items is None: items = []` से नई लिस्ट बनाना है। यहाँ `if not items:` के बजाय `if items is None:` जाँचना जरूरी है, ताकि यदि कॉलर स्वयं कोई खाली लिस्ट `[]` भेजे तो उसी लिस्ट में बदलाव हो न कि नई लिस्ट बने। यदि None स्वयं एक वैध इनपुट हो सकता है, तो `_MISSING = object()` जैसा अद्वितीय सेंटिनल उपयोग कर `if items is _MISSING:` जाँचा जाता है। कभी-कभी मेमोआइज़ेशन कैश (`cache={}`) या लूप क्लोज़र में मान लॉक करने के लिए इस व्यवहार का जानबूझकर भी उपयोग किया जाता है।
Syntax, Formula & Technical Example (Default Parameter Values and Mutable Default Argument Trap)
def buggy(x, box=[]):
box.append(x)
return box
def safe(x, box=None):
if box is None:
box = []
box.append(x)
return box
print(buggy(1), buggy(2)) # [1, 2] [1, 2]
print(safe(1), safe(2)) # [1] [2]
Default Parameter Values and Mutable Default Argument Trap Quick Reference & Comparison Table
| Pattern / Attribute | Evaluation / Behavior | Recommendation |
|---|---|---|
| def f(a=10): | Immutable int evaluated once at def time | Safe; int cannot be mutated in place |
| def f(lst=[]): | Same list mutated across omitted calls | Unsafe trap; causes hidden state leakage |
| def f(lst=None): | Creates fresh list inside body via is None | Standard Pythonic fix for mutable defaults |
| func.__defaults__ | Tuple storing positional default values | Inspects or exposes persisted default objects |
Default Parameter Values and Mutable Default Argument Trap Top 20 Bilingual MCQs with Answers
Q1. When does Python evaluate default parameter expressions in a `def` statement?
(पायथन `def` स्टेटमेंट में डिफ़ॉल्ट पैरामीटर एक्सप्रेशन का मूल्यांकन कब करता है?)
(A) Once at function definition time when def executes
(B) Only when the argument is omitted at call time
(C) At program exit
(D) Every time the function is called
Correct Answer: (A)
[EN] Python evaluates defaults exactly once when executing def and stores them on the function object.
[HI] पायथन डिफ़ॉल्ट मानों का मूल्यांकन केवल एक बार तब करता है जब def चलता है और उन्हें फंक्शन ऑब्जेक्ट में सहेजता है।
Q2. What does this code print? def add(x, lst=[]): lst.append(x) return lst print(add(1)) print(add(2))
(निम्न कोड क्या प्रिंट करेगा? def add(x, lst=[]): lst.append(x) return lst print(add(1)) print(add(2)))
(A) [1] followed by [2]
(B) [1] followed by [1, 2]
(C) TypeError
(D) [1] followed by [1]
Correct Answer: (B)
[EN] The same default list object is reused across both calls, so 2 appends to the list already containing 1.
[HI] दोनों कॉल्स में वही एक साझा डिफ़ॉल्ट लिस्ट उपयोग होती है, इसलिए दूसरे कॉल में [1, 2] बनता है।
Q3. What is the output of: def f(x, a=[]): a.append(x) return a print(f(1), f(2, []), f(3))
(निम्न कोड का आउटपुट क्या होगा? def f(x, a=[]): a.append(x) return a print(f(1), f(2, []), f(3)))
(A) [1, 3] [2] [1, 3]
(B) [1, 2, 3] [2] [1, 2, 3]
(C) [1] [2] [1, 3]
(D) [1] [2] [3]
Correct Answer: (A)
[EN] Wait carefully: f(1) appends 1 to the default list, f(2, []) mutates a fresh caller list [2], and f(3) mutates the default list to [1, 3]—and because f(1) and f(3) are both evaluated inside print(...) before printing, both expressions reference the same list [1, 3]!
[HI] f(1) और f(3) दोनों एक ही डिफ़ॉल्ट लिस्ट ऑब्जेक्ट लौटाते हैं, जो print() चलते समय [1, 3] बन चुकी होती है, जबकि f(2, []) नई लिस्ट [2] देता है।
Q4. Which function attribute stores the evaluated default values of positional parameters?
(पोजिशनल पैरामीटर्स के मूल्यांकित डिफ़ॉल्ट मान फंक्शन के किस एट्रिब्यूट में संग्रहीत होते हैं?)
(A) __dict__
(B) __annotations__
(C) __defaults__
(D) __init__
Correct Answer: (C)
[EN] Positional/standard parameter defaults are stored as a tuple in `func.__defaults__`.
[HI] सामान्य/पोजिशनल पैरामीटर्स के डिफ़ॉल्ट मान टपल के रूप में `func.__defaults__` में स्टोर रहते हैं।
Q5. Which attribute stores default values of keyword-only parameters (placed after `*`)?
(कीवर्ड-ओनली पैरामीटर्स (`*` के बाद वाले) के डिफ़ॉल्ट मान किस एट्रिब्यूट में संग्रहीत होते हैं?)
(A) __kwdefaults__
(B) __kwlist__
(C) __defaults__
(D) __kwargs__
Correct Answer: (A)
[EN] Keyword-only default values are stored as a dictionary in `func.__kwdefaults__`.
[HI] कीवर्ड-ओनली पैरामीटर्स के डिफ़ॉल्ट मान डिक्शनरी के रूप में `func.__kwdefaults__` में रहते हैं।
Q6. What happens when you define `def test(a=5, b): return a + b`?
(`def test(a=5, b): return a + b` परिभाषित करने पर क्या होता है?)
(A) SyntaxError: parameter without a default follows parameter with a default
(B) b defaults to None automatically
(C) It works if b is passed by keyword
(D) TypeError when calling test(1)
Correct Answer: (A)
[EN] Before `*`, non-default parameters cannot follow parameters with default values.
[HI] `*` से पहले, डिफ़ॉल्ट मान वाले पैरामीटर के बाद बिना डिफ़ॉल्ट वाला पैरामीटर लिखने पर SyntaxError आता है।
Q7. What is the idiomatic fix for `def register(item, target=[]):`?
(`def register(item, target=[]):` की म्यूटेबल डिफ़ॉल्ट त्रुटि सुधारने का मानक तरीका क्या है?)
(A) def register(item, target=[]): del target
(B) def register(item, target=tuple()): target.append(item)
(C) def register(item, target=None): if target is None: target = []
(D) def register(item, target=list()):
Correct Answer: (C)
[EN] Using `None` as default and checking `if target is None:` ensures a fresh list on every omitted call (note `target=list()` still creates only one list at def time!).
[HI] `None` डिफ़ॉल्ट रखकर अंदर `if target is None: target = []` लिखने से हर बार नई लिस्ट बनती है (जबकि `list()` भी def के समय एक ही बार चलता है)।
Q8. Why is `if items is None:` preferred over `if not items:` inside the None sentinel fix?
(None सेंटिनल समाधान में `if not items:` की तुलना में `if items is None:` क्यों बेहतर है?)
(A) Because `is None` runs 100x faster than `not` only on integers
(B) Because `if not items:` would falsely replace an explicit empty list [] passed by the caller
(C) Because None is truthy in Python
(D) Because `if not items:` raises TypeError on lists
Correct Answer: (B)
[EN] If a caller intentionally passes an empty list to be populated in place, `if not items:` treats `[]` as falsy and creates a new list instead.
[HI] यदि कॉलर जानबूझकर कोई खाली लिस्ट `[]` भरने के लिए भेजे, तो `if not items:` उसे असत्य मानकर नई लिस्ट बना देगा, जबकि `is None` ऐसा नहीं करता।
Q9. What happens with `def foo(items=list()):` compared to `def foo(items=[]):`?
(`def foo(items=[]):` की तुलना में `def foo(items=list()):` लिखने पर क्या होता है?)
(A) Both suffer from the exact same mutable default trap
(B) list() makes the default immutable
(C) list() creates a fresh list on every call safely
(D) list() raises SyntaxError as a default
Correct Answer: (A)
[EN] Because `list()` is evaluated once at `def` time, it creates one shared mutable list just like `[]`.
[HI] `list()` का मूल्यांकन भी `def` समय पर एक ही बार होता है, इसलिए यह भी `[]` की तरह ही एक साझा म्यूटेबल लिस्ट बनाता है।
Q10. What happens if you use `x = 10` then `def f(y=x): return y`, then set `x = 20`, and call `f()`?
(यदि `x = 10` के बाद `def f(y=x): return y` लिखा जाए, फिर `x = 20` करके `f()` कॉल किया जाए, तो क्या मिलेगा?)
(A) 20
(B) 10
(C) UnboundLocalError
(D) None
Correct Answer: (B)
[EN] Default argument `y=x` is bound to `10` at the moment `def` executes; later rebinding `x = 20` does not change `f.__defaults__`.
[HI] `def` चलते समय ही `y` का डिफ़ॉल्ट मान `10` से जुड़ जाता है; बाद में `x = 20` बदलने का डिफ़ॉल्ट पर कोई असर नहीं पड़ता।
Q11. What problem occurs with `def log_event(msg, when=datetime.now()):`?
(`def log_event(msg, when=datetime.now()):` लिखने पर क्या समस्या आएगी?)
(A) Every call omitting `when` gets the identical timestamp from when `def` ran
(B) TypeError on second invocation
(C) SyntaxError because function calls cannot be defaults
(D) when is always None
Correct Answer: (A)
[EN] `datetime.now()` runs once during module/function definition, freezing the timestamp across all future calls.
[HI] `datetime.now()` केवल परिभाषा के समय एक बार चलता है, जिससे हर कॉल में वही पुराना समय रिकॉर्ड होता रहता है।
Q12. Is `def func(a=1, *, b): return a + b` valid Python syntax?
(क्या `def func(a=1, *, b): return a + b` पायथन में वैध सिंटैक्स है?)
(A) Yes; keyword-only parameters after `*` do not need defaults even if `a` has one
(B) No; SyntaxError because b has no default
(C) Only in Python 2.7
(D) No; TypeError because * cannot follow a=1
Correct Answer: (A)
[EN] The non-default-before-default ordering restriction applies only among positional parameters; keyword-only parameters after `*` may omit defaults freely.
[HI] डिफ़ॉल्ट का क्रम नियम केवल पोजिशनल पैरामीटर्स पर लागू होता है; `*` के बाद कीवर्ड-ओनली पैरामीटर `b` बिना डिफ़ॉल्ट के हो सकता है।
Q13. Which default value type is SAFE from shared-mutation bugs across calls?
(कौन-सा डिफ़ॉल्ट मान प्रकार सभी कॉल्स के बीच म्यूटेशन बग से सुरक्षित (SAFE) है?)
(A) set
(B) list
(C) Immutable types such as int, str, float, bool, None, or a tuple of immutables
(D) dict
Correct Answer: (C)
[EN] Immutable objects cannot be modified in place, so sharing their reference in `__defaults__` is safe.
[HI] अपरिवर्तनीय (immutable) ऑब्जेक्ट्स जैसे int, str, None या टपल में इन-प्लेस बदलाव संभव नहीं है, अतः वे सुरक्षित हैं।
Q14. What should you use as the sentinel default if `None` itself is a valid argument the caller might pass?
(यदि `None` स्वयं एक वैध मान हो जो कॉलर भेज सकता है, तो डिफ़ॉल्ट सेंटिनल के रूप में क्या उपयोग करना चाहिए?)
(A) A global boolean flag
(B) A unique sentinel instance such as `_MISSING = object()`
(C) An empty list `[]`
(D) An integer `-1`
Correct Answer: (B)
[EN] `object()` creates a guaranteed unique instance that can never collide with any caller-supplied value including `None`, `False`, or `0`.
[HI] `object()` एक अद्वितीय सेंटिनल ऑब्जेक्ट बनाता है जो `None`, `False` या `0` जैसे किसी भी इनपुट से कभी मेल नहीं खाता।
Q15. What does `def f(a=1, b=2): pass; print(f.__defaults__)` print?
(`def f(a=1, b=2): pass; print(f.__defaults__)` क्या प्रिंट करेगा?)
(A) [1, 2]
(B) (1, 2)
(C) {'a': 1, 'b': 2}
(D) None
Correct Answer: (B)
[EN] Positional/standard parameter defaults are stored in order as a tuple in `__defaults__`.
[HI] डिफ़ॉल्ट मान क्रम से एक टपल `(1, 2)` के रूप में `__defaults__` में स्टोर होते हैं।
Q16. Which statement about default parameters in Python is NOT true?
(पायथन में डिफ़ॉल्ट पैरामीटर्स के बारे में निम्नलिखित में से कौन-सा कथन असत्य (NOT true) है?)
(A) Mutable defaults persist changes across calls when omitted
(B) Python re-evaluates `def f(x=[]):` to create a fresh empty list on every call
(C) Default expressions are evaluated once at function definition time
(D) Using `None` and creating the mutable object inside the body avoids shared state
Correct Answer: (B)
[EN] Python evaluates `[]` only once when `def` executes, never automatically per call.
[HI] पायथन `def` चलते समय `[]` का मूल्यांकन केवल एक बार करता है, हर कॉल पर नई लिस्ट नहीं बनाता।
Q17. Within Default Parameter Values and Mutable Default Argument Trap, which pattern / attribute directly maps to: "Immutable int evaluated once at def time"?
(Default Parameter Values and Mutable Default Argument Trap में कौन सा Pattern / Attribute सीधे "Immutable int evaluated once at def time" से संबंधित है?)
(A) def f(lst=[]):
(B) def f(lst=None):
(C) def f(a=10):
(D) func.__defaults__
Correct Answer: (C)
[EN] In Default Parameter Values and Mutable Default Argument Trap, 'def f(a=10):' handles 'Immutable int evaluated once at def time' (Safe; int cannot be mutated in place).
[HI] Default Parameter Values and Mutable Default Argument Trap में 'def f(a=10):' का कार्य/विवरण 'Immutable int evaluated once at def time' (Safe; int cannot be mutated in place) है।
Q18. Which option accurately describes 'def f(lst=[]):' in Default Parameter Values and Mutable Default Argument Trap?
(Default Parameter Values and Mutable Default Argument Trap के संदर्भ में 'def f(lst=[]):' की सही विशेषता कौन सी है?)
(A) Tuple storing positional default values
(B) Creates fresh list inside body via is None
(C) Same list mutated across omitted calls
(D) Immutable int evaluated once at def time
Correct Answer: (C)
[EN] 'def f(lst=[]):' provides 'Same list mutated across omitted calls' — key point: Unsafe trap; causes hidden state leakage.
[HI] 'def f(lst=[]):' का मुख्य विवरण 'Same list mutated across omitted calls' है (Unsafe trap; causes hidden state leakage)।
Q19. In Default Parameter Values and Mutable Default Argument Trap, identify the correct parameter for the specification: "Creates fresh list inside body via is None".
(Default Parameter Values and Mutable Default Argument Trap में "Creates fresh list inside body via is None" विवरण किस विकल्प के लिए सही है?)
(A) def f(a=10):
(B) func.__defaults__
(C) def f(lst=None):
(D) def f(lst=[]):
Correct Answer: (C)
[EN] 'def f(lst=None):' corresponds to 'Creates fresh list inside body via is None' (Standard Pythonic fix for mutable defaults).
[HI] 'def f(lst=None):' का संबंध 'Creates fresh list inside body via is None' (Standard Pythonic fix for mutable defaults) से है।
Q20. Considering Default Parameter Values and Mutable Default Argument Trap, what key behavior defines 'func.__defaults__'?
(Default Parameter Values and Mutable Default Argument Trap में 'func.__defaults__' की मुख्य भूमिका या मान क्या है?)
(A) Immutable int evaluated once at def time
(B) Creates fresh list inside body via is None
(C) Tuple storing positional default values
(D) Same list mutated across omitted calls
Correct Answer: (C)
[EN] 'func.__defaults__' represents 'Tuple storing positional default values' (Inspects or exposes persisted default objects).
[HI] 'func.__defaults__' का अर्थ/मान 'Tuple storing positional default values' है (Inspects or exposes persisted default objects)।
Default Parameter Values and Mutable Default Argument Trap — Exam FAQs
Q1: Why did Python's designers make default values evaluate once at `def` time instead of per call?
पायथन के निर्माताओं ने डिफ़ॉल्ट मानों का मूल्यांकन हर कॉल के बजाय `def` समय पर एक बार क्यों रखा?
[EN] Evaluating defaults once at definition time avoids overhead on every call, treats `def` consistently as an executable statement, and allows capturing loop variables or building static lookup defaults efficiently.
[HI] परिभाषा समय पर एक बार मूल्यांकन करने से हर कॉल की गति तेज रहती है, `def` एक सामान्य निष्पादन योग्य स्टेटमेंट की तरह काम करता है, और स्टैटिक डिफ़ॉल्ट्स कुशलता से बनते हैं।
Q2: Are mutable defaults like `t=(1, 2)` safe if the tuple contains a list inside it, like `t=([],)`?
क्या `t=([],)` जैसा टपल डिफ़ॉल्ट रूप से सुरक्षित है यदि उसके अंदर एक लिस्ट हो?
[EN] No! Although the outer tuple cannot be resized, the inner list inside `t[0]` is still mutable and will be shared across calls if mutated.
[HI] नहीं! यद्यपि बाहरी टपल अपरिवर्तनीय है, पर उसके अंदर मौजूद `t[0]` लिस्ट अभी भी म्यूटेबल है और सभी कॉल्स के बीच साझा रहेगी।
Q3: Can linters automatically catch mutable default arguments in Python?
क्या पायथन लिंटर्स म्यूटेबल डिफ़ॉल्ट आर्गुमेंट्स की गलती को अपने आप पकड़ सकते हैं?
[EN] Yes. Popular tools like Ruff/Flake8 (rule B006), Pylint (W0102 dangerous-default-value), and PyCharm flag mutable defaults automatically.
[HI] हाँ। Ruff/Flake8 (नियम B006), Pylint (W0102) और PyCharm जैसे टूल्स म्यूटेबल डिफ़ॉल्ट का उपयोग होने पर तुरंत चेतावनी देते हैं।
Post a Comment
Post a Comment