def with_metaclass(meta, *bases):
class metaclass(meta):<EOL><INDENT>__call__ = type.__call__<EOL>__init__ = type.__init__<EOL>def __new__(cls, name, this_bases, d):<EOL><INDENT>if this_bases is None:<EOL><INDENT>return type.__new__(cls, name, (), d)<EOL><DEDENT>return meta(name, bases, d)<EOL><DEDENT><DEDENT>return metaclass('<STR_LIT>', None, {})<EOL>
Defines a metaclass.

    Creates a dummy class with a dummy metaclass. When subclassed, the
    dummy metaclass is used, which has a constructor that instantiates a
    new class from the original parent. This ensures that the dummy
    class and dummy metaclass are not in the inheritance tree.

    Credit to Armin Ronacher.