Constructor
A constructor is a block of code that's executed when its class object is instantiated.
Python Example
For more Python class related examples, see:
# Define a class containing a constructor. class SampleClass: name = "" # Define the constructor to be executed when the class object is created. def __init__(self): self.name = "Sample Class" # Define a method as part of the class. def printname(self): print(self.name) # Create an object using the class. sampleobject = SampleClass() # Use the object. sampleobject.printname()