I have a function that creates classes derived from it's arguments:
def factory(BaseClass) :
class NewClass(BaseClass) : pass
NewA = factory(ClassA)
NewB = factory(ClassB)
print type(NewA()) # <class __main__.NewClass>
print type(NewB()) # <class __main__.NewClass>
NewA.__name__ = 'NewA'
print type(NewA()) # <class __main__.NewA>
__name__ is the correct thing to do; you don't need to set anything else to adjust the class name.
def factory(BaseClass) : class NewClass(BaseClass): pass NewClass.__name__ = "factory_%s" % BaseClass.__name__ return NewClass
type is the wrong thing to use here. It doesn't let you define classes with Python's normal class syntax, instead making you set up every class attribute manually. It's used to create classes by hand, eg. if you have an array of base classes and you want to create a class using it (which you can't do with Python's class syntax). Don't use it here.