How would I implement behavioural and creational patterns (adapter) in python?
Also singleton in here please
This is my code:
class Sock():
def connect(self):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(0.05)
try:
s.connect((self.ip_address, self.port))
s.send("Helloo")
result = s.recv(2048)
print(result)
except socket.timeout:
continue
I am calling this method from this class in another class, like: from Sock import Sock
socket = Sock()
socket.connect()
Aucun commentaire:
Enregistrer un commentaire