Start of retreat
I just found out what metaclasses are in Python. I do not think that the creators of python wanted everyone to use them. I mean, to call something a metaclass, which cannot be a class in most cases, is enough to distract most people from this concept!
Retreat End
On my question. I wrote this simple metaclass to add a default doc string for all classes created in the module. But it does not work:
def metest(cls,name,bases,dict): cls.setattr(cls,'__doc__',"""Default Doc""") return type(cls,(),{}) __metaclass__=metest class test(object): pass print test.__doc__ t=test() print t.__doc__
Conclusion:
None None
What am I doing wrong?
source share