Since we are going to save student information, the class is going to be called Student. A class is defined using the class keyword as follows:
Thus, a class called Student has been defined. Whenever a new object is created, the method __init__() (the underscore indicate that the init method is a magic method, that is it is a function that is called by Python when an object is created) is called internally by Python. This method is defined within the class:
class Student(object): """A Python class to store student information""" def __init__(self, name, address, age): self.name = name self.address = address self.age = age
In this example, the arguments to the __init__ method include name, age and address ...