<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def lookup_task(self, task):
 """ Looks up a task by name or by callable """

        if isinstance(task, str):
            try:
                return self[task]
            except KeyError:
                pass
        raise TaskError('Unknown task %s' % task)