def METHOD_NAME(self, lines, keywd, p, old_val, new_val, limit=1):
    ''' Replace a parameter's value with a new one, using optional match '''
    def assemble(indent, param, value, comment):
        ''' Helper function for line reassembly '''
        return indent + param + ' = ' + value + comment + '\n'
    replaced = 0
    i = 0
    kwd_found = False
    while replaced < limit and i < len(lines):
        line = lines[i]
        if kwd_found == True:   # Found the section with our keyword
            if line.find(p) >= 0 and line.find('=') >= 0:
                indent, param, value, comment = self.splitup(line)
                if old_val != '':
                    if value.find(old_val) >= 0:
                        lines[i] = assemble(indent, param, str(new_val), comment)
                        replaced += 1
                else:
                    lines[i] = assemble(indent, param, str(new_val), comment)
                    replaced += 1
        elif line.find(keywd) >= 0:
            kwd_found = True
        i += 1
    return replaced