Printing __doc__

Bart Ogryczak B.Ogryczak at gmail.com
Thu Mar 22 12:36:51 EDT 2007


On Mar 21, 8:47 pm, "gtb" <goodTweetieB... at hotmail.com> wrote:
> 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
>     #....

print eval(n+'.__doc__')







More information about the Python-list mailing list