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) :
>>> 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.
>>> x=type('x',(),dict(__doc__='hi there'))
> 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.
That's what the dict parameter is for:
>>> T = type("T", (object,), dict(__doc__="what you want"))
'what you want'
yes, you're right ... a subsequent question, that puzzles me:
where can I apply for the "most-stupid-question"-award, now *g*
- harold -
The opposite of a correct statement is a false statement.
But the opposite of a profound truth may be another profound truth.
-- Niels Bohr