code: def set_trace():
      
      # https://github.com/nose-devs/nose/blob/master/nose/tools/nontrivial.py
      pdb.Pdb(stdout=sys.__stdout__).set_trace(sys._getframe().f_back)
docs: Start a Pdb instance at the calling frame, with stdout routed to sys.__stdout__.