

This brings us to our next section, that is, the significance of self. Notice that while defining the method we passed an argument self, but while calling the method we didn’t pass any value to that argument. We call a method on an object using the dot notation. Now, invoke the method show() on the object d. This creates an object d of class Display. Go to the Python shell and type the following: > d = Display()

We can then invoke the method on the newly created object. To invoke a method, we first need to create an object of the class.
#Python3 class method map how to#
Now let’s see how to create objects and use this method. It prints the string written inside the parenthesis.This is the statement written inside the method’s suite.The colon ( : ) specifies the start of a suite.It takes a single argument self, written inside the parenthesis.A method, much like a normal function, starts with a def keyword.This entire thing which is written inside the class suite is a method. Let’s remove the pass keyword and add a method to our Display class. The class looks empty right? Well, let’s add some behavior to this class.

