Search the courses, subjects, tracks, games and features, or jump straight to a page.
3 cards from this section. Quick, good the night before a test.
What parameters does the exit method receive?
Think about what details are necessary for error management.
What happens if exit returns True?
Consider what you want to happen to exceptions.
What does the exit method do when an exception occurs?
Remember how exceptions are handled in context managers.
True or False: Returning False from exit suppresses the exception.
Consider what you want the program to do with errors.
Design a context manager that logs exceptions to a file instead of suppressing them.
Consider using file I/O techniques in your __exit__.
Create a context manager that differentiates between warnings and critical exceptions.
Think about using the built-in warnings library in Python!
5 more questions in this section. Enroll free to practise them all.
Enroll free