INFO1110 Lecture Notes - Lecture 2: Init, Order Of Merit, Harper Lee
Document Summary
We can think of classes as a template for all the variables and methods of a particular kind of object. Consider books as an example: all books have certain properties, or attributes. For example: title, author, year of publication, etc: if we de ne a template for the creation of such objects, we can easily keep track of all the data relating to that one speci c item. This also allows us to make multiple different instances of that class, i. e. making and storing data for lots of different books. A constructor tells you how to build an object. It creates a space in memory for the object when it is called. In python, we declare the constructor using __init__. self is a keyword to describe and refer to the instance of the class. class book: def __init__(self, title, author, year): self. title = title self. author = author self. year = year.