'get variables from stream as dictionary
Parameters
variable_names : None or str or sequence of str, optional
variable name, or sequence of variable names to get from Mat file /
file stream.  If None, then get all variables in file'

def get_variables(self, variable_names=None):

    if isinstance(variable_names, string_types):
        variable_names = [variable_names]
    elif (variable_names is not None):
        variable_names = list(variable_names)
    self.mat_stream.seek(0)
    self.initialize_read()
    mdict = {}
    while (not self.end_of_stream()):
        (hdr, next_position) = self.read_var_header()
        name = asstr(hdr.name)
        if ((variable_names is not None) and (name not in variable_names)):
            self.mat_stream.seek(next_position)
            continue
        mdict[name] = self.read_var_array(hdr)
        self.mat_stream.seek(next_position)
        if (variable_names is not None):
            variable_names.remove(name)
            if (len(variable_names) == 0):
                break
    return mdict
