Q52: What utilities do the 'tempfile' and 'shutil' modules provide?

  • tempfile: Creates secure temporary files and directories (NamedTemporaryFile, TemporaryDirectory) auto-cleaned on exit.
  • shutil: High-level file operations (shutil.copy(), shutil.move(), shutil.rmtree(), shutil.make_archive()).
Key Takeaways
  • tempfile: Secure temporary file lifecycle management.
  • shutil: High-level filesystem and archive operations.
Knowledge Check

Which function recursively deletes an entire directory tree along with all its contents?