Context managers (with statement)

  1. Why use context managers?
  2. Context Manager examples
  3. cd in a function
  4. open in function
  5. open in for loop
  6. open in function using with
  7. Plain context manager
  8. Param context manager
  9. Context manager that returns a value
  10. Use my tempdir - return
  11. Use my tempdir - exception
  12. cwd context manager
  13. tempdir context manager
  14. Context manager with class
  15. Context managers with class
  16. Context manager: with for file
  17. With - context managers
  18. Exercise: Context manager
  19. Exercise: Tempdir on Windows
  20. Solution: Context manager