Python utility functions for I/O