# __init__() behaves like a constructor and invoked automatically at the time of object declaration along with initialization of all the required members with default values or values provided at the time of declaration of object
class Motivation:
? ? def __init__(self):
? ? ? ? print("we have initialized our journey")
#object declaration? ? ? ??
motive = Motivation()
#output
we have initialized our journey
# __new__() method will be called whenever a object is created before the __init__() method to create the object taking "cls" as a parameter which is the class which needs to be instantiated.
class Organization:
? ? def __new__(cls):
? ? ? ? print("we are looking forward to be stable with unstable thoughts")
? ? ? ? return super(Organization, cls).__new__(cls)
? ? ? ??
? ? def __init__(self):
? ? ? ? print("we need self motivating employees with demotivated environment")
#object declaration?
employee = Organization()
#output
we are looking forward to be stable with unstable thoughts
we need self motivating employees with demotivated environment
# __new__ without return
class Employee:
? ? def __new__(cls):
? ? ? ? print("need growth in every possible way along with self respect")
? ? ? ? print("without returning proper input, can't get proper output everytime on intialization")
? ? ? ??
? ? def __init__(self):
? ? ? ? print("unable to give output")
#object declaration?
growth = Employee()
print(growth)
#output
need growth in every possible way along with self respect
without returning proper output, can't get proper input everytime on
intialization
None
# __init__ method is called every time an instance of the class is returned by __new__ method