Function docstring as a local variable

Carl Banks pavlovevidence at gmail.com
Tue Jul 12 00:11:17 CEST 2011


On Sunday, July 10, 2011 4:06:27 PM UTC-7, Corey Richardson 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?

It prints the module docstring, same as your example does.  You did realize that was the question I was answering, right?


Carl Banks



More information about the Python-list mailing list