Function docstring as a local variable
alex23
wuwei23 at gmail.com
Mon Jul 11 00:14:11 EDT 2011
On Jul 11, 9:06 am, Corey Richardson <kb1... at aim.com> wrote:
> Excerpts from Carl Banks's message of Sun Jul 10 18:59:02 -0400 2011:
>
> > print __doc__
>
> Python 2.7.1 (r271:86832, Jul 8 2011, 22:48:46)
> [GCC 4.4.5] on linux2
> Type "help", "copyright", "credits" or "license" for more information.>>> def foo():
>
> ... "Docstring"
> ... print __doc__
> ...
>
> >>> foo()
> None
>
> What does yours do?
Is foo() declared in a module with a docstring? Because that's what
Carl was talking about.
test_module.py:
'''module docstring'''
def foo():
print __doc__
Works for me.
More information about the Python-list
mailing list