Function docstring as a local variable

Corey Richardson kb1pkl at aim.com
Sun Jul 10 19:00:11 EDT 2011


Excerpts from Colin J. Williams's message of Sun Jul 10 18:28:15 -0400 2011:
> Try:
> 
> def f():
>       ds= """docstring"""
>       print ds

That doesn't actually make a docstring, though. It makes a string object and
points the name ds at it. Do you know what a docstring is?

def foo():
    """I am a docstring"""
    pass

def bar():
    ds = "I am not a docstring!"

def baz():
    "I am a docstring too!"
    pass

def qux():
    'And even me! Quote type don't matter (besides style)'
     pass
-- 
Corey Richardson
  "Those who deny freedom to others, deserve it not for themselves"
     -- Abraham Lincoln
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20110710/ef966a03/attachment-0001.sig>


More information about the Python-list mailing list