Issue 1678077: improve telnetlib.Telnet so option negotiation becomes easie (original) (raw)

(1) In the example code, why is parms backquoted? My first thought was that it was for repr, which won't work in Py3, particularly since it isn't quoted on the previous line.

(2) There are advantages to the old callback way. It is easier to change things per-instance, at runtime, and even mid-connection. It might be worth showing an example that restores the current model.

option_callback=None # class default
def set_option_negotiation_callback(self, callback):
    """Provide a callback function called after each receipt of a telnet option."""
    self.option_callback = callback

def handle_option(self, command, option):
    if self.option_callback is not None:
        return self.option_callback(self, command, option)