<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def template_class_from_name(name):
 """ Return the template class object from agiven name. """

    # import the right template module
    term = TerminalView()
    template_name = name + 'Template'
    try:
        __import__('projy.templates.' + template_name)
        template_mod = sys.modules['projy.templates.' + template_name]
    except ImportError:
        term.print_error_and_exit("Unable to find {}".format(name))

    # import the class from the module
    try:
        template_class = getattr(template_mod, template_name)
    except AttributeError:
        term.print_error_and_exit("Unable to create a template {}".format(name))
    return template_class()