zlib Error -3

Steve Holden sholden at holdenweb.com
Tue Jan 8 07:16:43 EST 2002


"DeepBleu" <DeepBleu at DeepBleu.org> wrote in message
news:O0t_7.89017$6m1.2776791 at typhoon.austin.rr.com...
> I see that I can get the text string content of a text file out of a
> compressed zip file, and I can write this string into a new text file
using
> two methods:
>
> If Bytes = text string
> 1.  File = open(NewFile, "w")
>      File.write(Bytes)
>      File.close()
> OR
> 2.  fd=os.open(NewFile, O_CREAT | O_WRONLY)
>     File = os.fdopen(fd)
>     os.write(fd, Bytes)
>     File.close()
>
> Can someone offer a hint on the difference between the two methods of
> writing the same file?

Method 2 is just a little more complex, and gives you a little more control
that method 1, which is perfectly adequate for most normal applications
(those, I mean, for which it is perfectly adequate).

The os-module functions are easier if you need to pass files between your
Python code and extension code in C, which uses file descriptors, but aren't
needed for most normal Python-only applicatins unless you are paranoid about
fine-grained contrl over file operations.

regards
 Steve

--
http://www.holdenweb.com/








More information about the Python-list mailing list