close

[Solved] Type: __init__() missing 2 required positional arguments: ‘client_socket’ and ‘statusMessage’

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Type: init() missing 2 required positional arguments: ‘client_socket’ and ‘statusMessage’ in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Type: init() missing 2 required positional arguments: ‘client_socket’ and ‘statusMessage’ Error Occurs?

Today I get the following error Type: init() missing 2 required positional arguments: ‘client_socket’ and ‘statusMessage’ in python.

How To Solve Type: init() missing 2 required positional arguments: ‘client_socket’ and ‘statusMessage’ Error ?

  1. How To Solve Type: init() missing 2 required positional arguments: 'client_socket' and 'statusMessage' Error ?

    To Solve Type: init() missing 2 required positional arguments: 'client_socket' and 'statusMessage' Error If you want to allow passing no arguments to the Class initiator, you have to define the initiator with default values set to None (or whatever is appropriate).

  2. Type: init() missing 2 required positional arguments: 'client_socket' and 'statusMessage'

    To Solve Type: init() missing 2 required positional arguments: 'client_socket' and 'statusMessage' Error If you want to allow passing no arguments to the Class initiator, you have to define the initiator with default values set to None (or whatever is appropriate).

Solution 1

If you want to allow passing no arguments to the Class initiator, you have to define the initiator with default values set to None (or whatever is appropriate).

For example,

def __init__(self, client_socket=None, statusMessage=""):
    self.client_socket = client_socket
    self.statusMessage = statusMessage

Now you can call your class instantiation without passing initialization parameters.

client = SimpleClient()

Solution 2

class SimpleClient:
    def __init__(self, client_socket, statusMessage):

Your class taking two arguments, but when you call it;

client = SimpleClient()

You didn’t write any arguments. So you have to put 2 arguments they may be None.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read