Skip to content Skip to sidebar Skip to footer

Typeerror: __init__() Missing 2 Required Positional Arguments: 'client_socket' And 'statusmessage'

import socket import sys class SimpleClient: def __init__(self, client_socket, statusMessage): self.client_socket = client_socket self.statusMessage = statusMe

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:

classSimpleClient: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.

Post a Comment for "Typeerror: __init__() Missing 2 Required Positional Arguments: 'client_socket' And 'statusmessage'"