pydoc preference for triple double over triple single quotes -- anyreason?

Brian van den Broek bvande at po-box.mcgill.ca
Sun Apr 17 12:47:11 EDT 2005


Kent Johnson said unto the world upon 2005-04-16 16:41:
> Brian van den Broek wrote:
> 
>> Hi all,
>>
>> I'm posting partly so my problem and solution might be more easily 
>> found by google, and partly out of mere curiosity.
>>
>> I've just spent a frustrating bit of time figuring out why pydoc 
>> didn't extract a description from my module docstrings. Even though I 
>> had a well formed docstring (one line, followed by a blank line, 
>> followed by the rest of the docstring), when I ran Module docs, my 
>> modules showed up as having "no description". ("Module docs" referring 
>> to the shortcut installed on Windows that launches the pydoc server.)
> 
> 
> ?? It works for me with triple-single quoted strings...from a quick look 
> it appears that pydoc uses inspect which looks at the __doc__ attribute; 
> do your modules have __doc__ attributes?
> 
> Kent


Thanks for the reply, Kent. (Also to Thomas in another reply addressed 
below.)

Kent, that's odd. My module does have a valid docstring and hence a 
__doc__ attribute (I did explicitly check). help(my_module) works fine 
at the prompt. It is just the results list in the TKinter interface to 
the pydoc server application that doesn't seem to pick up my module's 
description (in the first line of its docstring) when the docstring is 
triple-single quoted.

Either way, it's no big deal; my post was at least as much to have a 
googleable record of the situation as to figure out why. That said, it 
still does puzzle me that the pydoc server treats the two styles of 
triple quoted docstrings differently on my system (Python 2.4.1, 
Windows Me).

Thomas suggested the preference might be related to Emacs 
behaviour--that is something I know little about :-)

He also suggested that it could be that pydoc is following the PEP 257 
<http://www.python.org/peps/pep-0257.html> recommendation to use 
triple-double quoting. That might be, but if that's the explanation, 
it just pushes the puzzle up a level for me :-)

Anyway, thanks again to both,

Brian vdB




More information about the Python-list mailing list