<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def createConnection(self):
 """Return a CardConnection to the Card object."""

        readerobj = None
        if isinstance(self.reader, Reader):
            readerobj = self.reader
        elif type(self.reader) == str:
            for reader in readers():
                if self.reader == str(reader):
                    readerobj = reader

        if readerobj:
            return readerobj.createConnection()
        else:
            # raise CardConnectionException(
            # 'not a valid reader: ' + str(self.reader))
            return None