<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def show(self, dialog):

 """Generic method to show a non-modal dialog and keep reference
 to the Qt C++ object"""

        for dlg in list(self.dialogs.values()):
            if to_text_string(dlg.windowTitle()) \
               == to_text_string(dialog.windowTitle()):
                dlg.show()
                dlg.raise_()
                break
        else:
            dialog.show()
            self.dialogs[id(dialog)] = dialog
            dialog.accepted.connect(
                              lambda eid=id(dialog): self.dialog_finished(eid))
            dialog.rejected.connect(
                              lambda eid=id(dialog): self.dialog_finished(eid))