The simplest class possible is shown in the following example.
Example 11.1. Simplest Class
#!/usr/bin/python # Filename : simplestclass.py class Person: pass # A new block p = Person() print p
We create a new class using the class statement followed by the name of the class (Person in this case),followed by a block of statements with a higher level of indentation which forms the body of the class. In this case, we have an empty block which is indicated using the pass statement.
Next, we create an object (instance) of this class using the name of the class followed by a pair of parentheses. We will discuss instantiation of objects in more detail later. For our verification, we confirm the type of the variable i.e. object using the print statement. Notice that the address and the type of the object is printed. The address will have a different value on your computer, but the type confirms that we have indeed created an object of the class Person.