On Mon, May 4, 2009 at 6:37 PM, Tim Michelsen
<timmichel...@gmx-topmail.de> wrote:

> Who can I reference the docstring of a function within the function itself?

You can refer to the function by name inside the function. By the time
the body is actually executed, the name is defined:
In [1]: def show2(s):
   ...:     """prints s"""
   ...:     print s
   ...:     print show2.__doc__

In [2]: show2("test")
test
prints s

> Please have a look at the code below and assist me.
>
> def show(str):
>    """prints str"""
>    print str

It's a good idea not to use the names of builtins, such as 'str', as
variable names in your program.

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to