in my helper.py I have a class and a function definition:
class Suites():
NAME_SUITE = ['NATE', 'TOM', 'TED', 'JAN', 'SAM']
def check_suite(name, suite):
my_suite = Suites[suite] #I want my_suite to = ['NATE', 'TOM', 'TED', 'JAN', 'SAM']
return name in suite #I want to return True or False
and in views.py I'm trying to find out that user_in_suite is True
from .helper import check_suite
from .helper import Suites
def apps(request):
user_name = 'NATE'
suite_to_check = 'NAME_SUITE'
user_in_suite = check_suite(name=user_name, suite=suite_to_check)
But I'm getting an error for helper.py: 'classobj' object has no attribute '__getitem__
name in getattr(Suites(), suite)but that looks like code nightmare to me... what are you actually trying to accomplish here?NAME_SUITEneed to be in a class of its own and why do you need to reference it via a string rather than just calling the variable?