Function docstring as a local variable

python at bdurham.com python at bdurham.com
Mon Jul 11 00:13:29 CEST 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