def rpdb(F):
    """
    robot python debugger -- usage:
    @rpdb
    def keyword_method(self, arg1, arg2, ...):
        # stuff here ...
        rpdb.set_trace() # set breakpoint as usual
        # more code ...
    """
    setattr(rpdb, 'set_trace', pdb.set_trace)
    builtinIO = IO(sys)
    def _inner(*args, **kwargs):
        robotIO = IO(sys) # robot has hijacked stdin/stdout
        pdb.sys.stdin, pdb.sys.stdout = builtinIO
        retval = F(*args, **kwargs)
        sys.stdin, sys.stdout = robotIO
        return retval
    return _inner

    robot python debugger -- usage:
    @rpdb
    def keyword_method(self, arg1, arg2, ...):
        # stuff here ...
        rpdb.set_trace() # set breakpoint as usual
        # more code ...
    
recipes/Python/578073_RPDB_RobotPythonDebugger__smarter_way_debug/recipe-578073.py