[issue23217] help() function incorrectly captures comment preceding a nested function

anupama srinivas murthy report at bugs.python.org
Mon Jan 19 11:16:56 CET 2015


anupama srinivas murthy added the comment:

In Python 2.7, the capture happens even if there is no decorator. The code:
#Hey this is f
def f():

 return
 
help(f)
gives the output:
Help on function f in module __main__:

f()
    #Hey this is f
whereas a docstring inside the function causes the comment to be ignored. Therefore, the code:
#Hey this is f
def f():
 '''this is the function f'''
 return
 
help(f)
gives the output:
Help on function f in module __main__:

f()
    this is the function f
@Gwenllina:I need to clarify my previous comment. The docstring that would cause the preceding comment to be ignored must be in the inner function in case of the first example. Placing it in f() still causes comment capture as you said

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23217>
_______________________________________


More information about the Python-bugs-list mailing list