PEP: Specialization Syntax
Nicolas Fleury
nid_oizo at yahoo.com_removethe_
Mon Aug 8 04:03:21 EDT 2005
Kay Schluehr wrote:
> def makeClass(cls_name, **kw):
> return type(cls_name,(), kw)
>
>>>>MyObject = makeClass("MyObject",a=8)
>>>>MyObject
As said to Bengt, a place is needed to write the class definition.
There's no need for metaclass in that case:
def makeType(a, b, c=someDefault):
arguments = locals()
class MyObject:
pass # Complete definition here
MyObject.__dict__.update(arguments)
return MyObject
Regards,
Nicolas
More information about the Python-list
mailing list