This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author marco.buttu
Recipients marco.buttu
Date 2012-10-29.11:58:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1351511930.82.0.59071323276.issue16355@psf.upfronthosting.co.za>
In-reply-to
Content
The documentation for `inspect.getcomments()` says that it returns 
the "lines of comments immediately preceding an object's source code".
It works fine for the comments that immediately preceded an object 
defined in a module:

$ more foo.py 
import inspect
# A dummy comment
def foo():
    pass

print(inspect.getcomments(foo))
$ python3.3 foo.py 
# A dummy comment

But it does not work if we define an object interactively:

$ python3.3
Python 3.3.0 (default, Oct  9 2012, 18:20:32) 
[GCC 4.5.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import inspect
>>> # A dummy comment
... def foo():
...     pass
... 
>>> inspect.getcomments(foo)
>>> # A dummy comment
... 
>>> def foo():
...     pass
... 
>>> inspect.getcomments(foo)
>>>
History
Date User Action Args
2012-10-29 11:58:50marco.buttusetrecipients: + marco.buttu
2012-10-29 11:58:50marco.buttusetmessageid: <1351511930.82.0.59071323276.issue16355@psf.upfronthosting.co.za>
2012-10-29 11:58:50marco.buttulinkissue16355 messages
2012-10-29 11:58:50marco.buttucreate