<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def prepare_read(data, method='readlines', mode='r'):
 """Prepare various input types for parsing. Args: data (iter):
 Data to read method (str):
 Method to process data with mode (str):
 Custom mode to process with, if data is a file Returns: list: List suitable for parsing Raises: TypeError: Invalid value for data """

    if hasattr(data, 'readlines'):
        data = getattr(data, method)()
    elif isinstance(data, list):
        if method == 'read':
            return ''.join(data)
    elif isinstance(data, basestring):
        data = getattr(open(data, mode), method)()
    else:
        raise TypeError('Unable to handle data of type %r' % type(data))
    return data