(self, new_mode)
Switch tape to reading or writing mode.
Switch tape to reading or writing mode.
Switch tape to reading or writing mode .
def switch_mode(self, new_mode):
        """Switch tape to reading or writing mode."""
        self.flush()
        if self.operating_mode == 'w' and new_mode == 'r':
            self.current_byte = self.cas.read(1)
        elif self.operating_mode == 'r' and new_mode == 'w':
            self.cas.seek(-1, 1)
        self.operating_mode = new_mode
def switch_mode ( self , new_mode ) : self . flush ( ) if self . operating_mode == 'w' and new_mode == 'r' : self . current_byte = self . cas . read ( 1 ) elif self . operating_mode == 'r' and new_mode == 'w' : self . cas . seek ( - 1 , 1 ) self . operating_mode = new_mode