Cant overload python socket.send
- by ralu
Code
from socket import socket
class PolySocket(socket):
def __init__(self,*p):
print "PolySocket init"
socket.__init__(self,*p)
def sendall(self,*p):
print "PolySocket sendall"
return socket.sendall(self,*p)
def send(self,*p):
print "PolySocket send"
return socket.send(self,*p)
def connect(self,*p):
print "connecting..."
socket.connect(self,*p)
print "connected"
HOST="stackoverflow.com"
PORT=80
readbuffer=""
s=PolySocket()
s.connect((HOST, PORT))
s.send("a")
s.sendall("a")
Output:
PolySocket init
connecting...
connected
PolySocket sendall
As we can see, send method is not overloaded.