From 39f61ae3b7fbc1fffbe3470de8865ee041c7980a 2012-11-08 18:50:45 From: Bradley M. Froehle Date: 2012-11-08 18:50:45 Subject: [PATCH] Add pfile command to ipdb. --- diff --git a/IPython/core/debugger.py b/IPython/core/debugger.py index c71e6c8..94d84c3 100644 --- a/IPython/core/debugger.py +++ b/IPython/core/debugger.py @@ -492,6 +492,15 @@ class Pdb(OldPdb): ('Globals', self.curframe.f_globals)] self.shell.find_line_magic('pdoc')(arg, namespaces=namespaces) + def do_pfile(self, arg): + """Print (or run through pager) the file where an object is defined. + + The debugger interface to %pfile. + """ + namespaces = [('Locals', self.curframe.f_locals), + ('Globals', self.curframe.f_globals)] + self.shell.find_line_magic('pfile')(arg, namespaces=namespaces) + def do_pinfo(self, arg): """Provide detailed information about an object. diff --git a/IPython/core/magics/namespace.py b/IPython/core/magics/namespace.py index 8c16a3e..92f886b 100644 --- a/IPython/core/magics/namespace.py +++ b/IPython/core/magics/namespace.py @@ -98,7 +98,7 @@ class NamespaceMagics(Magics): self.shell._inspect('psource',parameter_s, namespaces) @line_magic - def pfile(self, parameter_s=''): + def pfile(self, parameter_s='', namespaces=None): """Print (or run through pager) the file where an object is defined. The file opens at the line where the object definition begins. IPython @@ -111,7 +111,7 @@ class NamespaceMagics(Magics): viewer.""" # first interpret argument as an object name - out = self.shell._inspect('pfile',parameter_s) + out = self.shell._inspect('pfile',parameter_s, namespaces) # if not, try the input as a filename if out == 'not found': try: