Re: [Tutor] GzipFile has no attribute '__exit__'

2009-11-16 Thread Sander Sweers
2009/11/16 Kent Johnson : > You might want to report this as a bug against 2.6 and submit this > change as a proposed fix. It's easy to do, see I poked around in the bug tracker and found [1]. It will be in 2.7 and was *not* accepted for 2.6. If anyone wants to add this in themselves see [2]. Gr

Re: [Tutor] GzipFile has no attribute '__exit__'

2009-11-16 Thread Kent Johnson
On Mon, Nov 16, 2009 at 7:15 AM, Sander Sweers wrote: > This triggered my to dig into this a bit. This is not fixed untill > python 3.1 but seems easilly added to the ZipFile class. My attempt to > backport this from python 3.1's gzip.py below seems to work. > > Greets > Sander > > import gzip >

Re: [Tutor] GzipFile has no attribute '__exit__'

2009-11-16 Thread Sander Sweers
2009/11/16 Dave Angel : > Alternatively, you could subclass it, and write your own.  At a minimum, the > __exit__() method should close() the stream. This triggered my to dig into this a bit. This is not fixed untill python 3.1 but seems easilly added to the ZipFile class. My attempt to backport t

Re: [Tutor] GzipFile has no attribute '__exit__'

2009-11-16 Thread Dave Angel
Stephen Nelson-Smith wrote: 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", lin

Re: [Tutor] GzipFile has no attribute '__exit__'

2009-11-16 Thread Kent Johnson
On Mon, Nov 16, 2009 at 5:58 AM, Stephen Nelson-Smith wrote: > 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 (m

[Tutor] GzipFile has no attribute '__exit__'

2009-11-16 Thread Stephen Nelson-Smith
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 with gzip.open('