Cant overload python socket.send?

I am sure you don't actually need it and there are other ways to solve your task (not subclassing but the real task).

I am sure you don't actually need it and there are other ways to solve your task (not subclassing but the real task). If you really need to mock object, go with proxy object: from socket import socket class PolySocket(object): def __init__(self, *p): print "PolySocket init" self. _sock = socket(*p) def __getattr__(self, name): return getattr(self.

_sock, name) def sendall(self, *p): print "PolySocket sendall" return self. _sock. Sendall(*p) def send(self, *p): print "PolySocket send" return self.

_sock. Send(*p) def connect(self, *p): print "connecting..." self. _sock.

Connect(*p) print "connected" HOST = "stackoverflow. Com" PORT = 80 readbuffer = "" s = PolySocket() s. Connect((HOST, PORT)) s.

Send("a") s. Sendall("a") Here's the output: % python foo. Py PolySocket init connecting... connected PolySocket send PolySocket sendall.

Thanks, that was just great. – ralu May 14 '10 at 14:04.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions