ZIP files

Michael Foord fuzzyman at gmail.com
Mon Nov 15 16:51:08 CET 2004


[snip..]
> I'd suggest to expand this a bit, and make it working correctly on
> windows too, where binary files must be opened with the 'b' flag:
> 
> def _write_data(filename, data, flags):
>     fileobject = open(filename, flags)
>     try: fileobject.write(data)
>     finally: fileobject.close()
> 
> def write_data(filename, data, flags="wb"):
>     _write_data(filename, data, flags)
> 
> def write_text(filename, text, flags="w"):
>     _write_data(filename, data, flags)
> 
> plus the corresponding read_data() and read_text() functions.
> Hm, add an encoding for unicode, maybe...
> Cookbook recipe, or standard lib?
> 
> Thomas


Hmm...I have a set of functions as a module - readfile, writefile,
readlines, writelines. My guess is that *everyone* has a similar
module they've written themselves. It can be a PITA cutting and
pasting the functions for a single line job sometimes. It would be a
useful addition to the standard lib.

Regards,

Fuzzy



More information about the Python-list mailing list