def sendcommand(self, cmd, opt=None):
if cmd in [DO, DONT]:<EOL><INDENT>if not self.DOOPTS.has_key(opt):<EOL><INDENT>self.DOOPTS[opt] = None<EOL><DEDENT>if (((cmd == DO) and (self.DOOPTS[opt] != True))<EOL>or ((cmd == DONT) and (self.DOOPTS[opt] != False))):<EOL><INDENT>self.DOOPTS[opt] = (cmd == DO)<EOL>self.writecooked(IAC + cmd + opt)<EOL><DEDENT><DEDENT>elif cmd in [WILL, WONT]:<EOL><INDENT>if not self.WILLOPTS.has_key(opt):<EOL><INDENT>self.WILLOPTS[opt] = '<STR_LIT>'<EOL><DEDENT>if (((cmd == WILL) and (self.WILLOPTS[opt] != True))<EOL>or ((cmd == WONT) and (self.WILLOPTS[opt] != False))):<EOL><INDENT>self.WILLOPTS[opt] = (cmd == WILL)<EOL>self.writecooked(IAC + cmd + opt)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>self.writecooked(IAC + cmd)<EOL><DEDENT>
Send a telnet command (IAC)