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
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
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: