and app_or_project if app_or_project equals to string 'app', if not, it is replaced with 'a' and app_or_project. call the method re.search with 2 arguments: raw string '^[_a-zA-Z]\w*$' and name, if it evaluates to false,
if not re . search ( r'^[_a-zA-Z]\w*$' , name ) :