On 5/4/2009 3:37 PM Tim Michelsen said...
Dear Tutors and fellow pythonistas,
I would like to get access to the private methods of my function.
For instance:
Who can I reference the docstring of a function within the function itself?
<snip>
def show2(str):
"""prints str"""
print str
d = self.__doc__
print d
>>> def show2(str):
... """prints str"""
... print str
... print globals()['show2'].__doc__
...
>>> show2('hello')
hello
prints str
>>>
This is the easy way -- ie, you know where to look and what name to use.
You can discover the name using the inspect module, but it can get
ugly. If you're interested start with...
from inspect import getframeinfo, currentframe
HTH,
Emile
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor