human
Can you provide a the Python code you requested given the following:
I am working on the file "Section 1 - Core Python/Chapter 09 - Classes & OOPS/01_Classes_and_OOPS.ipynb".
The first task is:
both super(MyNewTest, cls).__new__(cls) and object.__new__(cls) produce the desired instance as shown in the above examples.
If we were to return anything other than instance of object, then __init__ function will never be called as shown in the below example.
Can you write Python code for it?
assistant
#Here is the Python code you requested.

class Distance(float):        
    def __new__(cls, dist):
        print("in __new__", dist)
        return dist*0.0254
    
    # __init__ is redundent in this example, 
    # as it will never be called. 
    def __init__(self, dist):    
        print("in __init__", dist)
    
    def print_dist(self):
        print(self.__name__)
        
try:
    mnt = Distance(22)
    print(mnt, type(mnt))
    mnt.print_dist()
except Exception as e:
    print(e)

class Distance(float):        
    def __new__(cls, dist):
        print("in __new__", dist)
        instance =  super(Distance, cls).__new__(cls)
        print(type(instance))
        instance.val = dist*0.0254
        return instance
    
    def __init__(self, dist):    
        print("in __init__", dist)
    
    def print_dist(self):
        print(self.val)
        

if __name__ == "__main__":
    try:
        mnt = Distance(22)
        print(mnt, type(mnt))
        mnt.print_dist()
    except Exception as e:
        print(e)