def METHOD_NAME(self, var):
    """
    Replace invalid variable chars in a string by underscores
    Taken from https://stackoverflow.com/a/3305731/438386
    """
    return re.sub(r'\W|^(?=\d)', '_', var)