Example #1
0
 def __new__(cls, *args, **kwargs):
     if not cls.__instance:
         obj = object.__new__(cls)
         obj.socket = MySocketClient()
         obj.username = None
         cls.__instance = obj
     return cls.__instance
Example #2
0
 def __init__(self):
     self.socket = MySocketClient()
     self.username = None
Example #3
0
 def __init__(self):
     self.socket = MySocketClient()  # 组合:一个对象的属性是另一个类的对象
     self.username = None
 def __init__(self):
     self.sk = MySocketClient()  #感觉这里直接用self=MySocketClient()
     self.username = None