<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add(self, method_class, action, version=None):
 """Add a method class to the regitry. @param method_class: The method class to add @param action: The action that the method class can handle @param version: The version that the method class can handle """

        by_version = self._by_action.setdefault(action, {})
        if version in by_version:
            raise RuntimeError("A method was already registered for action"
                               " %s in version %s" % (action, version))
        by_version[version] = method_class