from pathlib import Path


def has_to_write(path_file: Path, new_code: str):
    """Check if a file exists and contains a code"""
    if path_file.exists():
        with open(path_file, "r") as file:
            source_code = file.read()
        if new_code == source_code:
            return False
        else:
            return True
    else:
        return True