Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > GzipFile as a Context manager

Thread Tools

GzipFile as a Context manager

Mikolai Fajer
Posts: n/a
Is there a reason that the gzip.GzipFile class does not have __enter__
and __exit__ methods that mimic those of the file object? I expected
the following to work but it doesn't:

import gzip
with'temp.gz', 'w') as fhandle:
gzip.write('Hello world.')

If there is no reason to avoid this behavior should I submit a bug
report and a subsequent patch? Thanks!


-Mikolai Fajer-
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to close a gzip.GzipFile? Justin Guerin Python 0 04-01-2005 06:54 PM
A problem with GzipFile (BUG?) Paulo da Silva Python 0 08-14-2004 01:00 AM