Function docstring as a local variable
ben+python at benfinney.id.au
Mon Jul 11 01:48:46 CEST 2011
"Colin J. Williams" <cjw at ncf.ca> writes:
> On 10-Jul-11 13:44 PM, rantingrick wrote:
> > On Jul 10, 12:41 pm, Tim Johnson<t... at johnsons-web.com> wrote:
> >> It possible for a function to print it's own docstring?
> > def f():
> > """docstring"""
> > print "docstring"
> def f():
> ds= """docstring"""
> print ds
The OP wants the function to print its own docstring, which your example
does not do. You've defined a function with an empty docstring.
>>> def foo():
... ds = "The Larch"
... print ds
\ “Firmness in decision is often merely a form of stupidity. It |
`\ indicates an inability to think the same thing out twice.” |
_o__) —Henry L. Mencken |
More information about the Python-list