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

Juan Christian juan0christian at gmail.com
Fri Sep 19 22:00:25 CEST 2014


On Fri, Sep 19, 2014 at 4:30 PM, Peter Otten <__peter__ at web.de> wrote:
>
> Well, you import closing from the stdlib with
>
> from contextlib import closing
>
> and then proceed to write your own closing
>
> @contextmanager
> def closing(thing):
>     try:
>         yield thing
>     finally:
>         thing.close()
>
> At the moment my advice would be: forget about closing and the with-
> statement. They are great to solve a problem you don't have (here).


So, just do as you said in the post above, 'status["steamrep_scammer"] =
"steamrep_scammer" in api' and use a single try-expect in the outer
requests.get() ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140919/aa0ea1e3/attachment.html>


More information about the Tutor mailing list