[Tutor] how to reference a function itself when accessing its private functions?
Tim Michelsen
timmichelsen at gmx-topmail.de
Tue May 5 00:37:53 CEST 2009
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?
Please have a look at the code below and assist me.
Thanks and regards,
Timmie
#### CODE ###
s = 'hello'
def show(str):
"""prints str"""
print str
return str
def show2(str):
"""prints str"""
print str
d = self.__doc__
print d
>>> show2(s)
hello
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython console> in <module>()
<ipython console> in show2(str)
NameError: global name 'self' is not defined
More information about the Tutor
mailing list