diff --git a/IPython/Magic.py b/IPython/Magic.py index 4a9ad34..0f9fae7 100644 --- a/IPython/Magic.py +++ b/IPython/Magic.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Magic functions for InteractiveShell. -$Id: Magic.py 2437 2007-06-14 18:24:38Z vivainio $""" +$Id: Magic.py 2464 2007-06-27 23:03:07Z vivainio $""" #***************************************************************************** # Copyright (C) 2001 Janko Hauser and @@ -58,6 +58,8 @@ from IPython.ipstruct import Struct from IPython.macro import Macro from IPython.genutils import * from IPython import platutils +import IPython.generics +import IPython.ipapi #*************************************************************************** # Utility functions @@ -528,6 +530,7 @@ Currently the magic system has the following functions:\n""" #print 'pinfo par: <%s>' % parameter_s # dbg + # detail_level: 0 -> obj? , 1 -> obj?? detail_level = 0 # We need to detect if we got called as 'pinfo pinfo foo', which can @@ -559,6 +562,11 @@ Currently the magic system has the following functions:\n""" info = Struct(self._ofind(oname, namespaces)) if info.found: + try: + IPython.generics.inspect_object(info.obj) + return + except IPython.ipapi.TryNext: + pass # Get the docstring of the class property if it exists. path = oname.split('.') root = '.'.join(path[:-1]) diff --git a/IPython/generics.py b/IPython/generics.py index e578c0b..09a1462 100644 --- a/IPython/generics.py +++ b/IPython/generics.py @@ -25,3 +25,6 @@ def result_display(result): result_display = generic(result_display) +def inspect_object(obj): + """ Called when you do obj? """ + raise TryNext diff --git a/doc/ChangeLog b/doc/ChangeLog index 95032ee..428eb5c 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -12,6 +12,8 @@ In practice, this kind of alias can take the role of a magic function + * New generic inspect_object, called on obj? and obj?? + 2007-06-14 Ville Vainio * iplib.py (handle_auto): Try to use ascii for printing "--->"