Printing __doc__

gtb goodTweetieBird at hotmail.com
Wed Mar 21 15:47:06 EDT 2007


Greetings,

Don't know the daily limit for dumb questions so I will ask one or
more.

In a function I can use the statement n =
sys._getframe().f_code.co_name to get the name of the current
function. Given that I can get the name how can I print the __doc__
string? I cant use the following, it will tell me to bugger off as the
string has no such attribute.

def spam(self):
    n = sys._getframe().f_code.co_name
    print n.__doc__      #Wrong
    print __doc__         #No good either
    #....


thanx,

gtb




More information about the Python-list mailing list