[Tutor] Using 'requests' + 'with statement' in Python 3.4.1

Joel Goldstick joel.goldstick at gmail.com
Fri Sep 19 20:08:06 CEST 2014


On Fri, Sep 19, 2014 at 2:00 PM, Juan Christian
<juan0christian at gmail.com> wrote:
> On Fri, Sep 19, 2014 at 2:50 PM, Danny Yoo <dyoo at hashcollision.org> wrote:
>>
>> So Python's "with" appears to require a bit more out the thing being
>> managed than the similar try-with-resources in Java.
>>
>> (http://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html)
>
>
>
> Is there anything similar in Python? Putting tons of 'try-expect' in the
> code would be a bit ugly.

You might want to look at decorators.  I think that might help you
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>



-- 
Joel Goldstick
http://joelgoldstick.com


More information about the Tutor mailing list