<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def section(self, regex, config='running_config'):
 """Returns a section of the config Args: regex (str):
 A valid regular expression used to select sections of configuration to return config (str):
 The configuration to return. Valid values for config are "running_config" or "startup_config". The default value is "running_config" Returns: The configuration section as a string object. """

        if config in ['running_config', 'startup_config']:
            config = getattr(self, config)
        match = re.search(regex, config, re.M)
        if not match:
            raise TypeError('config section not found')
        block_start, line_end = match.regs[0]

        match = re.search(r'^[^\s]', config[line_end:], re.M)
        if not match:
            raise TypeError('could not find end block')
        _, block_end = match.regs[0]

        block_end = line_end + block_end
        return config[block_start:block_end]