from textwrap import dedent


def cleanup(export: str = "__export__") -> str:
    """ Generate code to clean up the current namespace!
    
    Usage: `exec(cleanup())`
    """
    return dedent(
        f"""
        for variable in locals().copy():
            if variable != "{export}" and variable not in {export}:
                del locals()[variable]
        del variable, {export}
        """
    )