how to set doc-string of new-style classes

harold fellermann harold.fellermann at upf.edu
Tue Jan 11 13:26:58 EST 2005


Hello,

does anyone know a way to set the __doc__ string of a new style class?
Any attempt I tried results in the following error:

Python 2.4 (#1, Dec 30 2004, 08:00:10)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> class Foo(object) :
...     pass
...
 >>> Foo.__doc__ = "bar"
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
TypeError: attribute '__doc__' of 'type' objects is not writable

I can understand someone arguing that "changing a doc string is during
programm execution and should therefore be forbidden!" But, I cannot
even find out a way to set the doc string, when I CREATE a class using
type(name,bases,dict) ... At least this should be possible, IMHO.

- harold -

--
If you make people think they're thinking, they'll love you;
but if you really make them think they'll hate you.




More information about the Python-list mailing list