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:

class Student(object):

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): = name         self.address = address         self.age = age

In this example, the arguments to the __init__ method include name, age and address ...

Get Python Programming with Raspberry Pi now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.