class my_types:
def __init__(self):
self.my_types = [email_type, negotive_type, positive_type]
def check_types(self, check_type):
for my_type in self.my_types:
obj = my_type()
if obj.check_type(check_type):
return obj.type_name()
return "Unknown type"
class email_type(my_types):
def check_type(self, check_type):
if "@" in check_type:
return True
return False
def type_name(self):
return "email_type"
class negotive_type(my_types):
def check_type(self, check_type):
if "no" in check_type:
return True
return False
def type_name(self):
return "negotive_type"
class positive_type(my_types):
def check_type(self, check_type):
if "yes" in check_type:
return True
return False
def type_name(self):
return "positive_type"
check_types = ["test@", "yes", "no"]
obj = my_types()
for check_type in check_types:
print("{} - {}".format(check_type, obj.check_types(check_type)))
test@ - email_type
yes - positive_type
no - negotive_type