metaclasses

Simon Burton simonb at webone.com.au
Tue Jul 29 00:25:26 CEST 2003


It seems this is a more general way to build classes than inheritance.
Is this a reasonable viewpoint?

>>> 
>>> def meth1(self):
...   print "i am meth1"
... 
>>> def meth2(self):
...   print "i am meth2"
... 
>>> Foo = type("Foo",(),{'meth':meth1}) # make a class
>>> foo = Foo() # make an instance
>>> foo.meth() # call a method
i am meth1
>>> 

Simon.





More information about the Python-list mailing list