473,503 Members | 9,735 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to set doc-string of new-style classes

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.

Jul 18 '05 #1
3 1333
harold fellermann <ha***************@upf.edu> wrote:
...
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.

x=type('x',(),dict(__doc__='hi there'))
x.__doc__

'hi there'

Alex
Jul 18 '05 #2
harold fellermann wrote:
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"))
T.__doc__

'what you want'

Peter
Jul 18 '05 #3

On 11.01.2005, at 19:35, Alex Martelli wrote:
harold fellermann <ha***************@upf.edu> wrote:
...
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.

x=type('x',(),dict(__doc__='hi there'))
x.__doc__

'hi there'


yes, you're right ... a subsequent question, that puzzles me:
where can I apply for the "most-stupid-question"-award, now *g*

thanks anyway,

- 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

Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1444
by: Barry | last post by:
I'm looking for a control to us on our web site that will take our reports that are generated in PDF and convert them to DOC format all on the server. We are using win2k3 web servers if that helps....
5
4901
by: John Morgan | last post by:
I am using the following link to download a file of about 50k <a target= "_blank" href="http://www.bsecs.org.uk/ExecDocs/documentStore/elfridaWord.doc">open file</a> If I save the file to...
2
9846
by: Stu | last post by:
Hi, I have a Word document that is stored outside of the virtual server and I need to send it to the browser. I have tried using the code below (which seemed a little too simplistic!). The...
5
2386
by: monomaniac21 | last post by:
This one has been bugging me for months everytime i've tried i've had to give up and do something else. Anyone know how to do this, any help would be much appreciated. I think that I need to use...
13
11607
by: kbperry | last post by:
Hi all, Background: I need some help. I am trying to streamline a process for one of our technical writers. He is using Perforce (version control system), and is constantly changing his word...
1
9156
by: gslim | last post by:
I am trying to implement the busybox sample from // From Mark Wagner // http://blogs.crsw.com/mark/articles/642.aspx When I get to this line I get an access denied error. Could someone give me...
13
1441
by: LtCommander | last post by:
Hi all, I am trying to extract text from an uploaded DOC file so that I can do some regex on the text in order to fill up some textboxes on the ASP page. I know that Writely (www.writely.com)...
1
1411
by: arun raut | last post by:
On Apr 10, 10:32 pm, Rich <R...@discussions.microsoft.comwrote: help not compilation write all easier. But Rich, Without being sure completely, if you want to use HTML as help
3
4764
by: patrick.waldo | last post by:
Hi Everyone, I had previously asked a similar question,...
1
4376
by: setori88 | last post by:
Hi guys this script i downloaded from here, http://win32com.goermezer.de/index.php?option=com_content&task=view&id=193&Itemid=274 I copied this script and setup and instance of open office...
0
7095
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7294
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7361
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7470
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5602
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4693
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3173
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
749
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
403
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.