What does a with statement guarantee?
QuizMediumPython onlyAsked in: Infosys, TCS
A with statement uses a context manager: an object with __enter__ (runs at the start) and __exit__ (runs at the end). Which statements about with are true? Pick all that apply.
__exit__runs even if the block raises an exception- If
__exit__returns a false value, the exception continues after clean-up with open(path) as f:closes the file when the block ends- The value after
asis always the object written afterwith
This question is part of Pro+
Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.