On Wed, 24 Dec 2008 16:59:23 -0800, Mike Driscoll wrote:

>> Among my questions are:
>> """ A little thread we've added""" seems to be an isolated string. It
>> does not seem to be doing anything there, almost like a comment. Why is
>> it there?
> 
> 
> That's what some people call a doc string. 

Other people call it "Maurice". *wink*

A doc[umentation] string is the accepted name for it. Anytime a function, 
class or module starts immediately with a loan string, that string is 
stored by the Python compiler in an attribute __doc__. E.g.:

>>> def parrot(x):
...     "This is a doc string."
...     return "Norwegian Blue"
...
>>> parrot.__doc__
'This is a doc string.'


> It is like a comment in that
> it helps the user know what the function is for. Notice the triple
> quotes. 

Triple quotes are a red herring. Any string literal will do.


-- 
Steven
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to