Re: Printing __doc__

2007-03-22 Thread Bart Ogryczak
On Mar 21, 8:47 pm, "gtb" <[EMAIL PROTECTED]> 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 ho

Re: Printing __doc__

2007-03-21 Thread Terry Reedy
"Cameron Laird" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] || Peter is trying to communicate that some aspects of Python are | quite conservative, well-documented, and unlikely to change | across versions or implementations. The syntax of, let's say, | "def", is an example of su

Re: Printing __doc__

2007-03-21 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, gtb <[EMAIL PROTECTED]> wrote: >On Mar 21, 3:35 pm, Peter Otten <[EMAIL PROTECTED]> wrote: . . . >> >>> import sys >> >>> def docstring(): >> >> ... return sys._getframe(1).f_code.co_consts[0

Re: Printing __doc__

2007-03-21 Thread gtb
On Mar 21, 3:35 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > gtb wrote: > > 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 wi

Re: Printing __doc__

2007-03-21 Thread gtb
On Mar 21, 3:11 pm, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > "gtb" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > | 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._getfram

Re: Printing __doc__

2007-03-21 Thread Peter Otten
gtb wrote: > 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. > >

Re: Printing __doc__

2007-03-21 Thread Terry Reedy
"gtb" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | 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

Re: Printing __doc__

2007-03-21 Thread Josh Bloom
This will work, but I'm getting out of my depth as to whether its a good idea to do or not. import sys def testFunc(): ''' Here is my doc string''' n = sys._getframe().f_code.co_name print eval(n).__doc__ testFunc() The issue being that n is a simply a string containing the name of th

Printing __doc__

2007-03-21 Thread gtb
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