Print the source code for an object.
(self, obj, oname='')
| 475 | page.page('\n'.join(lines)) |
| 476 | |
| 477 | def psource(self, obj, oname=''): |
| 478 | """Print the source code for an object.""" |
| 479 | |
| 480 | # Flush the source cache because inspect can return out-of-date source |
| 481 | linecache.checkcache() |
| 482 | try: |
| 483 | src = getsource(obj, oname=oname) |
| 484 | except Exception: |
| 485 | src = None |
| 486 | |
| 487 | if src is None: |
| 488 | self.noinfo('source', oname) |
| 489 | else: |
| 490 | page.page(self.format(src)) |
| 491 | |
| 492 | def pfile(self, obj, oname=''): |
| 493 | """Show the whole file where an object was defined.""" |