Upload New File

parent 0a85a4dc
class LazySingleton:
_instance = None
def __new__(cls):
if cls._instance is None:
cls._instance = super(LazySingleton, cls).__new__(cls)
return cls._instance
if __name__ == "__main__":
singleton1 = LazySingleton()
singleton2 = LazySingleton()
print(singleton1 is singleton2)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment