def factory(msgtype, **kwargs):
for name, obj in inspect.getmembers(sys.modules[__name__]):<EOL><INDENT>if inspect.isclass(obj) and issubclass(obj, Message):<EOL><INDENT>try:<EOL><INDENT>if obj.__name__ == msgtype:<EOL><INDENT>return obj(**kwargs)<EOL><DEDENT><DEDENT>except AttributeError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT><DEDENT>
Factory method that can be used to easily instansiate a class instance

:param msgtype: The name of the class 
:param kwargs: Keyword arguments 
:return: An instance of the class or None if the name doesn't match any
    known class.