Message174108
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)
>>> |
|
Date |
User |
Action |
Args |
2012-10-29 11:58:50 | marco.buttu | set | recipients:
+ marco.buttu |
2012-10-29 11:58:50 | marco.buttu | set | messageid: <1351511930.82.0.59071323276.issue16355@psf.upfronthosting.co.za> |
2012-10-29 11:58:50 | marco.buttu | link | issue16355 messages |
2012-10-29 11:58:50 | marco.buttu | create | |
|