method 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: python list constructor
nuts = list("pecan nut", "walnut", "cashew nut", "macadamia nut")
forrests_favorites = list(nuts) # makes a new list with the same content