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

 """connect sysout to the qtSignal"""

        if writeToShell and not self._connected:
            self.message.connect(self.stdW)
            self._connected = True
        elif not writeToShell and self._connected:
            try:
                self.message.disconnect(self.stdW)
            except TypeError:
                pass  # was not connected
            self._connected = False