human
I am working on the file "Section 1 - Core Python/Chapter 09 - Classes & OOPS/01_Classes_and_OOPS.ipynb".
The first task is:
Where can we use __new__
Creating singleton class
In singleton pattern, we create one instance of the class and all subsequent objects of that class points to the first instance.
Lets try to create a singleton class using __new__ constructor.
Can you write Python code for it?
assistant
#Here is the Python code you requested.

class Godlike(object):
    
    def __new__(cls, name):
        it = cls.__dict__.get("__it__")
        if it is not None:
            return it
        cls.__it__ = it = object.__new__(cls)
        it.init(name)
        return it
    
    def init(self, name):
        self.name = name
    
    def print_name(self):
        print(self.name)
        
        
ohm = Godlike("Ohm")
ram = Godlike("ram")
hari = Godlike("hari")

print(ohm is ram)
print(ohm is hari)
ohm.print_name()
ram.print_name()