human
I wrote the below code

    def safe_remove(path):
        try:
            os.remove(path)
        except OSError as err:
            if (err.errno != errno.ENOENT):
                raise
        else:
            safe_print(('rm    %s' % path))
    def safe_rmtree(path):
        def onerror(fun, path, excinfo):
            exc = excinfo[1]
            if (exc.errno != errno.ENOENT):
                raise
        existed = os.path.isdir(path)
        shutil.rmtree(path, onerror=onerror)
        if existed:
            safe_print(('rmdir    -f    %s' % path))
    if ('*' not in pattern):
        if directory:
            safe_rmtree(pattern)
        else:
            safe_remove(pattern)
        return
    for (root, subdirs, subfiles) in os.walk('.'):
        root = os.path.normpath(root)
        if root.startswith('.git/'):
            continue
        found = fnmatch.filter((subdirs if directory else subfiles), pattern)
        for name in found:
            path = os.path.join(root, name)
            if directory:
                safe_print(('rmdir    -f    %s' % path))
                safe_rmtree(path)
            else:
                safe_print(('rm    %s' % path))
                safe_remove(path)

What's a good function header?
 ... Here's a good function header?
assistant
#Here's a good function header.

def rm(pattern, directory=False):