November 2018
Beginner
304 pages
7h 35m
English
Let's look at an example of creating a simple class and methods, plus some instances of the class:

The class is defined on line 22. We use the statement class, followed by the name of the class. Normally, when the class object is defined, there are no parentheses at the end; parentheses are only used for functions and methods. However, the old way of defining classes used parentheses, so you may see that in many programs you come across.
After the class is defined, two methods are defined as well: setName() and display(). The first argument in the parentheses for a method must be self. This is used ...
Read now
Unlock full access