<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def rm(path, recursive=False):
 """Delete a specified file or directory. This function does not recursively delete by default. OK """

    try:
        if recursive:
            if os.path.isfile(path):
                os.remove(path)
            else:
                shutil.rmtree(path)
        else:
            if os.path.isfile(path):
                os.remove(path)
            else:
                os.rmdir(path)
    except OSError as error:
        log.error('rm: execute failed: %s (%s)' % (path, error))
        return False
    return True