SarkariResultess QA Bank

AttributeError: 'NoneType' object has no attribute ... को कैसे debug करें? इसका quick fix क्या है? — interview में इसका सही जवाब क्या है?

Other 0 Views Verified
AttributeError: 'NoneType' object has no attribute ... को कैसे debug करें? इसका quick fix क्या है? — interview में इसका सही जवाब क्या है?
Sarkari Result QA Bank
Editorially reviewed exam information

Answer & Explanation

4 Answers
Verified Correct Answer

if obj is not None: obj.method()

if obj is not None: obj.method()
Additional Explanation
None पर attribute/method access करने से पहले value check करें।
Verified

None.method(obj)

None.method(obj)
Additional Explanation
यह विकल्प सही समाधान नहीं है।
Verified

obj.method() always without checking

obj.method() always without checking
Additional Explanation
यह विकल्प सही समाधान नहीं है।
Verified

obj = None.method()

obj = None.method()
Additional Explanation
यह विकल्प सही समाधान नहीं है।