human
Complete this python program:
def _rename(names, replace_str):
assistant
#Here is the Python code you requested.

    """For both rename and inline.
    """
    order = sorted(names, key=(lambda x: (x.module_path, x.line, x.column)), reverse=True)
    def process(path, old_lines, new_lines):
        if (new_lines is not None):
            dct[path] = (path, old_lines, new_lines)
    dct = {}
    current_path = object()
    new_lines = old_lines = None
    for name in order:
        if name.in_builtin_module():
            continue
        if (current_path != name.module_path):
            current_path = name.module_path
            process(current_path, old_lines, new_lines)
            if (current_path is not None):
                with open(current_path) as f:
                    source = f.read()
            new_lines = common.splitlines(common.source_to_unicode(source))
            old_lines = new_lines[:]
        (nr, indent) = (name.line, name.column)
        line = new_lines[(nr - 1)]
        new_lines[(nr - 1)] = ((line[:indent] + replace_str) + line[(indent + len(name.name)):])
    process(current_path, old_lines, new_lines)
    return dct