Re: How parametrize classes by class data?

2010-10-04 Thread Arnaud Delobelle
kj writes: > I want to implement a "class of classes", so that, instead of the > usual: > > spam = MyClass(eggs) > > ...I can write > > spam = MyClass(ham)(eggs) > > ...where ham is a parameter that will end up as the value of a class > variable of the class returned by MyClass(ham). > > In other

Re: How parametrize classes by class data?

2010-10-04 Thread Andreas Waldenburger
On Mon, 4 Oct 2010 15:59:51 + (UTC) kj wrote: > I want to implement a "class of classes", so that, instead of the > usual: > > spam = MyClass(eggs) > > ...I can write > > spam = MyClass(ham)(eggs) Use a factory function: def MyClass(param): class TemplateClass: # Do stuff wit

How parametrize classes by class data?

2010-10-04 Thread kj
I want to implement a "class of classes", so that, instead of the usual: spam = MyClass(eggs) ...I can write spam = MyClass(ham)(eggs) ...where ham is a parameter that will end up as the value of a class variable of the class returned by MyClass(ham). In other words, MyClass is a metaclass: