Re: with HTTPConnection as conn:

2010-11-18 Thread Hrvoje Niksic
Antoine Pitrou writes: > On Thu, 18 Nov 2010 12:46:07 +0100 > trylks wrote: >> Hi! >> >> Would it be possible to use a with statement with an HTTPConnection object? >> >> I know it is not possible at this moment, it doesn't implement an >> __exit__ method, at least in version 3.1.1. I was wond

Re: with HTTPConnection as conn:

2010-11-18 Thread Antoine Pitrou
On Thu, 18 Nov 2010 12:46:07 +0100 trylks wrote: > Hi! > > Would it be possible to use a with statement with an HTTPConnection object? > > I know it is not possible at this moment, it doesn't implement an > __exit__ method, at least in version 3.1.1. I was wondering if the > __exit__ method shou

Re: with HTTPConnection as conn:

2010-11-18 Thread Chris Rebert
On Thu, Nov 18, 2010 at 3:46 AM, trylks wrote: > Hi! > > Would it be possible to use a with statement with an HTTPConnection object? Yes, via http://docs.python.org/library/contextlib.html#contextlib.closing from httplib import HTTPConnection from contextlib import closing with closing(HTTPConn

with HTTPConnection as conn:

2010-11-18 Thread trylks
Hi! Would it be possible to use a with statement with an HTTPConnection object? I know it is not possible at this moment, it doesn't implement an __exit__ method, at least in version 3.1.1. I was wondering if the __exit__ method should do something more than conn.close(), something really hard or