Why give a local variable an initial value immediately before assigning to it?
def initiate_send(self): num_sent = 0 num_sent = dispatcher.send(self, self.out_buffer[:512]) self.out_buffer = self.out_buffer[num_sent:]
My question: Why is num_sent first set to 0, but then immediately set again to another value?
If i'd found this anywhere but in the python source code, I'd say that this line of code is superfluous. Is there any point to it, or is it dead code?
That's dead code; it's a local variable, so it is not ever going to influence anything else.
If it had been a instance variable, then dispatcher.send could have read the value while executing, but it's completely superfluous here.
The asyncore module is relatively ancient, the line has been there since it was first committed to the python codebase in 1999.