constructor in python code example
Example 1: python class constructor
class Human:
def __init__(self, name):
self.name = name
h1 = Human("Bob")
print(h1.name) # prints Bob, the name passed from constructor
Example 2: pyhon constructor
def __init__(self):
# body of the constructor