How parametrize classes by class data?

Andreas Waldenburger usenot at geekmail.INVALID
Mon Oct 4 18:05:14 CEST 2010


On Mon, 4 Oct 2010 15:59:51 +0000 (UTC) kj <no.email at please.post> 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 with param.
    return TemplateClass

/W

-- 
INVALID? DE!




More information about the Python-list mailing list