Run
def createClass(classname, attributes): return type(classname, (object,), { '__init__': lambda self, arg1, arg2: setattr(self, 'args', (arg1, arg2)), 'args': attributes }) Car = createClass('Car', {'name':'', 'age':0}) Student = createClass('Student', {'name':'', 'age':0}) mycar = Car('Audi R8', 3) print(f"Car name: {mycar.args[0]}\nCar age: {mycar.args[1]} years") student1 = Student('Ram', 12) print(f"Student name: {student1.args[0]}\nStudent age: {student1.args[1]} years")
Output