Bound method in Python

When you create a class, you usually also create methods. Some methods take arguments:

def start(one, two, three):

and there are ones that don’t take any arguments:

def start():

There are methods with the “self” argument at the beginning. It doesn’t have to be this particular word, you can use any other word, but the requirement is that it has to be the first argument.

def start(self, one, two, three):

or

def start(self):

Bound methods

The methods with the “self” argument at the beginning are the bound methods.

Let’s try them using the example:

class Car:
    def start(self):
        print('Engine started')

Now, you can create an instance of this class and run the “start” method.

bmw = Car()
bmw.start()

Now, let’s try to create an unbound method.

The unbound method is:

def start():

You cannot call this method using a class instance. Instead, you have to run like this:

Car.start()