Why doesn’t a string in parentheses make a tuple with just that string? [duplicate]

You’re trying to create a tuple, but you’re just parenthesizing a string 🙂

Add an extra ‘,’:

dRecieved = connFile.readline()
processThread = threading.Thread(target=processLine, args=(dRecieved,))  # <- note extra ','
processThread.start()

Or use brackets to make a list:

dRecieved = connFile.readline()
processThread = threading.Thread(target=processLine, args=[dRecieved])  # <- 1 element list
processThread.start()

If you notice, from the stack trace: self.__target(*self.__args, **self.__kwargs)

The *self.__args turns your string into a list of characters, passing them to the processLine
function. If you pass it a one element list, it will pass that element as the first argument – in your case, the string.

Leave a Comment