def user_from_str(identifier):
 try:
  user_id = int(identifier)
 except ValueError:
  return User.objects.get(email=identifier)
 return User.objects.get(id=user_id)

def user_from_str ( identifier ) : try : user_id = int ( identifier ) except ValueError : return User . objects . get ( email = identifier ) return User . objects . get ( id = user_id )
return a user identified by the given string .