[Tutor] GzipFile has no attribute '__exit__'

Stephen Nelson-Smith sanelson at gmail.com
Mon Nov 16 11:58:30 CET 2009


I'm trying to write a gzipped file on the fly:

merged_log = merge(*logs)

with gzip.open('/tmp/merged_log.gz', 'w') as output:
    for stamp, line in merged_log:
        output.write(line)

But I'm getting:

Traceback (most recent call last):
  File "./magpie.py", line 72, in <module>
    with gzip.open('/tmp/merged_log.gz', 'w') as output:
AttributeError: GzipFile instance has no attribute '__exit__'

What am I doing wrong, and how do I put it right?

S.


More information about the Tutor mailing list