Function docstring as a local variable

python at bdurham.com python at bdurham.com
Sun Jul 10 18:13:29 EDT 2011


I'm not sure how a function can get a generic handle to itself, but if
you're willing to hardcode the function name, then this technique works:

def test():
    """This is my doc string"""
    print test.__doc__

test()

Outputs:

This is my doc string

Malcolm



More information about the Python-list mailing list