x = 1 type(x) type(int) type(type) int("2") Point = type("Point", (object,), {"x": 0, "y": 0}) Point type(Point) Point2 = type("Point2", (), {}) type(Point2) class type2(type): pass A = type2("A", (), {}) A type(A) class B(object): __metaclass__ = type2 B type(B) # Can a metaclass be a string? def fakemeta(name, bases, attrs): return 1 class C(object): __metaclass__ = fakemeta C mapping = [] class metapage(type): def __init__(cls, name, bases, attrs): type.__init__(cls, name, bases, attrs) url = "/" + name mapping.append((url, cls)) class page: __metaclass__ = metapage print mapping class hello(page): def get(self): return "hello, world!" print mapping class bye(page): def get(self): return "goodbye!" print mapping # It is a common practice to base class construtor in the subclass class Point: def __init__(self, x, y): self.x = x self.y = y class Point3D(Point): def __init__(self, x, y, z): Point.__init__(self, x, y) self.z = z