diff --git a/IPython/core/debugger.py b/IPython/core/debugger.py index d733b30..b173a5a 100644 --- a/IPython/core/debugger.py +++ b/IPython/core/debugger.py @@ -477,23 +477,51 @@ class Pdb(OldPdb): do_l = do_list def do_pdef(self, arg): - """The debugger interface to magic_pdef""" + """Print the call signature for any callable object. + + The debugger interface to %pdef""" namespaces = [('Locals', self.curframe.f_locals), ('Globals', self.curframe.f_globals)] self.shell.find_line_magic('pdef')(arg, namespaces=namespaces) def do_pdoc(self, arg): - """The debugger interface to magic_pdoc""" + """Print the docstring for an object. + + The debugger interface to %pdoc.""" namespaces = [('Locals', self.curframe.f_locals), ('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): - """The debugger equivalant of ?obj""" + """Provide detailed information about an object. + + The debugger interface to %pinfo, i.e., obj?.""" + namespaces = [('Locals', self.curframe.f_locals), + ('Globals', self.curframe.f_globals)] + self.shell.find_line_magic('pinfo')(arg, namespaces=namespaces) + + def do_pinfo2(self, arg): + """Provide extra detailed information about an object. + + The debugger interface to %pinfo2, i.e., obj??.""" + namespaces = [('Locals', self.curframe.f_locals), + ('Globals', self.curframe.f_globals)] + self.shell.find_line_magic('pinfo2')(arg, namespaces=namespaces) + + def do_psource(self, arg): + """Print (or run through pager) the source code for an object.""" namespaces = [('Locals', self.curframe.f_locals), ('Globals', self.curframe.f_globals)] - self.shell.find_line_magic('pinfo')("pinfo %s" % arg, - namespaces=namespaces) + self.shell.find_line_magic('psource')(arg, namespaces=namespaces) def checkline(self, filename, lineno): """Check whether specified line seems to be executable. diff --git a/IPython/core/magics/namespace.py b/IPython/core/magics/namespace.py index 8c16a3e..36f2d02 100644 --- a/IPython/core/magics/namespace.py +++ b/IPython/core/magics/namespace.py @@ -69,7 +69,7 @@ class NamespaceMagics(Magics): @skip_doctest @line_magic def pdef(self, parameter_s='', namespaces=None): - """Print the definition header for any callable object. + """Print the call signature for any callable object. If the object is a class, print the constructor information. @@ -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: diff --git a/IPython/core/oinspect.py b/IPython/core/oinspect.py index dc4ab87..ba5f935 100644 --- a/IPython/core/oinspect.py +++ b/IPython/core/oinspect.py @@ -344,7 +344,7 @@ class Inspector: self.set_active_scheme(scheme) def _getdef(self,obj,oname=''): - """Return the definition header for any callable object. + """Return the call signature for any callable object. If any exception is generated, None is returned instead and the exception is suppressed.""" @@ -373,7 +373,7 @@ class Inspector: print() def pdef(self, obj, oname=''): - """Print the definition header for any callable object. + """Print the call signature for any callable object. If the object is a class, print the constructor information.""" diff --git a/docs/source/interactive/reference.txt b/docs/source/interactive/reference.txt index 225ed3c..4a7e706 100644 --- a/docs/source/interactive/reference.txt +++ b/docs/source/interactive/reference.txt @@ -337,7 +337,7 @@ this is just a summary: * **%pdoc **: Print (or run through a pager if too long) the docstring for an object. If the given object is a class, it will print both the class and the constructor docstrings. - * **%pdef **: Print the definition header for any callable + * **%pdef **: Print the call signature for any callable object. If the object is a class, print the constructor information. * **%psource **: Print (or run through a pager if too long) the source code for an object.