0

I have seen other questions about how to get (return) the name of a function, but the ones I read about do not seem to be about the same thing as in the code I am referring to here (although I am not 100% sure).

In telnetsrv 0.4 project (for Python 2.x) I came across the portion of code shown below (it belongs to file telnetsrvlib.py). What I don't understand is the logic of the last line – the one that says return self._inputcooker_getc(block). It looks to me like a snake that bytes his own tail.

Is this some form of comprehension ?
Can this be expanded somehow so it become less confusing (well, at least for me :) about what (or how) it actually returns ?

def _inputcooker_getc(self, block=True):
    """Get one character from the raw queue. Optionally blocking.
    Raise EOFError on end of stream. SHOULD ONLY BE CALLED FROM THE
    INPUT COOKER."""
    if self.rawq:
        ret = self.rawq[0]
        self.rawq = self.rawq[1:]
        return ret
    if not block:
        if not self.inputcooker_socket_ready():
            return ''
    ret = self.sock.recv(20)
    self.eof = not(ret)
    self.rawq = self.rawq + ret
    if self.eof:
        raise EOFError
    return self._inputcooker_getc(block)
secarica
  • 597
  • 5
  • 18

0 Answers0