[Python-ideas] make Connections iterable

Nick Coghlan ncoghlan at gmail.com
Mon Jan 8 22:34:31 EST 2018


On 9 January 2018 at 13:27, Amit Green <amit.mixie at gmail.com> wrote:

> An argument against this API, is that any caller of recv should be doing
> error handling (i.e.: catching exceptions from the socket).
>
> Changing into an iterator makes it less likely that error handling will be
> properly coded, and makes the error handling more obscure.
>
> Thus although the API would make the code more readable for the [wrong
> case] of not handling errors; the real issue is that it would make the code
> more obscure for the proper case of error handling.
>
> We should focus on the proper use case: using recv with error handling &
> thus not add this API.
>

It could be useful to include a recipe in the documentation that shows a
generator with suitable error handling (taking the generic connection
errors and adapting them to app specific ones) while also showing how to
adapt the connection to the iterator protocol, though.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180109/a01db2e0/attachment.html>


More information about the Python-ideas mailing list