On Thu, Nov 18, 2010 at 3:46 AM, trylks <try...@gmail.com> 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(HTTPConnection(...)) as conn:
    # do whatever
# connection now closed

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to