Updated as_variable_name to Python 3