Print the source code for an object.
(self, obj, oname='')
| 537 | page.page('\n'.join(lines)) |
| 538 | |
| 539 | def psource(self, obj, oname=''): |
| 540 | """Print the source code for an object.""" |
| 541 | |
| 542 | # Flush the source cache because inspect can return out-of-date source |
| 543 | linecache.checkcache() |
| 544 | try: |
| 545 | src = getsource(obj, oname=oname) |
| 546 | except Exception: |
| 547 | src = None |
| 548 | |
| 549 | if src is None: |
| 550 | self.noinfo('source', oname) |
| 551 | else: |
| 552 | page.page(self.format(src)) |
| 553 | |
| 554 | def pfile(self, obj, oname=''): |
| 555 | """Show the whole file where an object was defined.""" |