Which of the following is a recommended use case for custom context managers?

  • Basic arithmetic calculations.
  • Closing a file after reading/writing data
  • Sorting a list of integers.
  • Web scraping with BeautifulSoup.
A recommended use case for custom context managers is closing a file after reading or writing data. This ensures proper resource cleanup and prevents resource leaks when dealing with files.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *