Function docstring as a local variable

Corey Richardson kb1pkl at
Mon Jul 11 01:00:11 CEST 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"""

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

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

def qux():
    'And even me! Quote type don't matter (besides style)'
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: <>

More information about the Python-list mailing list