[Python-ideas] Tulip / PEP 3156 - subprocess events

Ben Darnell ben at bendarnell.com
Sat Jan 19 18:32:55 CET 2013


On Fri, Jan 18, 2013 at 8:23 PM, Glyph <glyph at twistedmatrix.com> wrote:

>
> On Jan 18, 2013, at 4:12 PM, Guido van Rossum <guido at python.org> wrote:
>
> On Fri, Jan 18, 2013 at 3:59 PM, Greg Ewing <greg.ewing at canterbury.ac.nz>
> wrote:
>
>
> Guido van Rossum wrote:
>
> Well, except that you can't just pass CallbackProtocol where a
> protocol factory is required by the PEP -- you'll have to pass a
> lambda or partial function without arguments that calls
> CallbackProtocol with some arguments taken from elsewhere.
>
>
> Something smells wrong to me about APIs that require protocol
> factories.
>
>
> For starters, nothing "smells wrong" to me about protocol factories.
>  Responding to this kind of criticism is difficult, because it's not
> substantive - what's the actual problem?  I think that some Python
> programmers have an aversion to factories because a common path to Python
> is flight from Java environments that over- or mis-use the factory pattern.
>
>
I think the smell is that the factory is A) only used once and B) invoked
without adding any additional arguments that weren't available when the
factory was passed in, so there's no clear reason to defer creation of the
protocol.  I think it would make more sense if the transport were passed as
an argument to the factory (and then we could get rid of connection_made as
a required method on Protocol, although libraries or applications that want
to separate protocol creation from connection_made could still do so in
their own factories).

-Ben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130119/fd43f2bb/attachment.html>


More information about the Python-ideas mailing list