def connectProtocol(endpoint, protocol):
 class OneShotFactory(Factory, ):
  def buildProtocol(self, addr):
   return protocol
 return endpoint.connect(OneShotFactory())

def connectProtocol ( endpoint , protocol ) : class OneShotFactory ( Factory , ) : def buildProtocol ( self , addr ) : return protocol return endpoint . connect ( OneShotFactory ( ) )
connect a protocol instance to an endpoint .