<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Module: core.oinspect — IPython 2.3.0 documentation</title> <link rel="stylesheet" href="../../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../', VERSION: '2.3.0', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../../_static/jquery.js"></script> <script type="text/javascript" src="../../_static/underscore.js"></script> <script type="text/javascript" src="../../_static/doctools.js"></script> <link rel="top" title="IPython 2.3.0 documentation" href="../../index.html" /> <link rel="up" title="The IPython API" href="../index.html" /> <link rel="next" title="Module: core.page" href="IPython.core.page.html" /> <link rel="prev" title="Module: core.magics.script" href="IPython.core.magics.script.html" /> </head> <body> <div style="background-color: white; text-align: left; padding: 10px 10px 15px 15px"> <a href="http://ipython.org/"><img src="../../_static/logo.png" border="0" alt="IPython Documentation"/></a> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="../../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="IPython.core.page.html" title="Module: core.page" accesskey="N">next</a> |</li> <li class="right" > <a href="IPython.core.magics.script.html" title="Module: core.magics.script" accesskey="P">previous</a> |</li> <li><a href="http://ipython.org">home</a>| </li> <li><a href="../../search.html">search</a>| </li> <li><a href="../../index.html">documentation </a> »</li> <li><a href="../index.html" accesskey="U">The IPython API</a> »</li> </ul> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="../../index.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">Module: <tt class="docutils literal"><span class="pre">core.oinspect</span></tt></a><ul> <li><a class="reference internal" href="#class">1 Class</a></li> <li><a class="reference internal" href="#functions">10 Functions</a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="IPython.core.magics.script.html" title="previous chapter">Module: <tt class="docutils literal"><span class="pre">core.magics.script</span></tt></a></p> <h4>Next topic</h4> <p class="topless"><a href="IPython.core.page.html" title="next chapter">Module: <tt class="docutils literal"><span class="pre">core.page</span></tt></a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../../_sources/api/generated/IPython.core.oinspect.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="../../search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="module-IPython.core.oinspect"> <span id="module-core-oinspect"></span><h1>Module: <tt class="xref py py-mod docutils literal"><span class="pre">core.oinspect</span></tt><a class="headerlink" href="#module-IPython.core.oinspect" title="Permalink to this headline">¶</a></h1> <p>Tools for inspecting Python objects.</p> <p>Uses syntax highlighting for presenting the various information elements.</p> <p>Similar in spirit to the inspect module, but all calls take a name argument to reference the name under which an object is being read.</p> <div class="section" id="class"> <h2>1 Class<a class="headerlink" href="#class" title="Permalink to this headline">¶</a></h2> <dl class="class"> <dt id="IPython.core.oinspect.Inspector"> <em class="property">class </em><tt class="descclassname">IPython.core.oinspect.</tt><tt class="descname">Inspector</tt><big>(</big><em>color_table={'': <IPython.utils.coloransi.ColorScheme instance at 0xf456676c></em>, <em>'LightBG': <IPython.utils.coloransi.ColorScheme instance at 0xf456678c></em>, <em>'NoColor': <IPython.utils.coloransi.ColorScheme instance at 0xf45663ac></em>, <em>'Linux': <IPython.utils.coloransi.ColorScheme instance at 0xf456676c>}</em>, <em>code_color_table={'': <IPython.utils.coloransi.ColorScheme instance at 0xf45aceac></em>, <em>u'LightBG': <IPython.utils.coloransi.ColorScheme instance at 0xf45acf2c></em>, <em>u'NoColor': <IPython.utils.coloransi.ColorScheme instance at 0xf45ace2c></em>, <em>u'Linux': <IPython.utils.coloransi.ColorScheme instance at 0xf45aceac>}</em>, <em>scheme='NoColor'</em>, <em>str_detail_level=0</em><big>)</big><a class="headerlink" href="#IPython.core.oinspect.Inspector" title="Permalink to this definition">¶</a></dt> <dd><dl class="method"> <dt id="IPython.core.oinspect.Inspector.__init__"> <tt class="descname">__init__</tt><big>(</big><em>color_table={'': <IPython.utils.coloransi.ColorScheme instance at 0xf456676c></em>, <em>'LightBG': <IPython.utils.coloransi.ColorScheme instance at 0xf456678c></em>, <em>'NoColor': <IPython.utils.coloransi.ColorScheme instance at 0xf45663ac></em>, <em>'Linux': <IPython.utils.coloransi.ColorScheme instance at 0xf456676c>}</em>, <em>code_color_table={'': <IPython.utils.coloransi.ColorScheme instance at 0xf45aceac></em>, <em>u'LightBG': <IPython.utils.coloransi.ColorScheme instance at 0xf45acf2c></em>, <em>u'NoColor': <IPython.utils.coloransi.ColorScheme instance at 0xf45ace2c></em>, <em>u'Linux': <IPython.utils.coloransi.ColorScheme instance at 0xf45aceac>}</em>, <em>scheme='NoColor'</em>, <em>str_detail_level=0</em><big>)</big><a class="headerlink" href="#IPython.core.oinspect.Inspector.__init__" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="method"> <dt id="IPython.core.oinspect.Inspector.info"> <tt class="descname">info</tt><big>(</big><em>obj</em>, <em>oname=''</em>, <em>formatter=None</em>, <em>info=None</em>, <em>detail_level=0</em><big>)</big><a class="headerlink" href="#IPython.core.oinspect.Inspector.info" title="Permalink to this definition">¶</a></dt> <dd><p>Compute a dict with detailed information about an object.</p> <p>Optional arguments:</p> <ul class="simple"> <li>oname: name of the variable pointing to the object.</li> <li>formatter: special formatter for docstrings (see pdoc)</li> <li>info: a structure with some information fields which may have been precomputed already.</li> <li>detail_level: if set to 1, more information is given.</li> </ul> </dd></dl> <dl class="method"> <dt id="IPython.core.oinspect.Inspector.noinfo"> <tt class="descname">noinfo</tt><big>(</big><em>msg</em>, <em>oname</em><big>)</big><a class="headerlink" href="#IPython.core.oinspect.Inspector.noinfo" title="Permalink to this definition">¶</a></dt> <dd><p>Generic message when no information is found.</p> </dd></dl> <dl class="method"> <dt id="IPython.core.oinspect.Inspector.pdef"> <tt class="descname">pdef</tt><big>(</big><em>obj</em>, <em>oname=''</em><big>)</big><a class="headerlink" href="#IPython.core.oinspect.Inspector.pdef" title="Permalink to this definition">¶</a></dt> <dd><p>Print the call signature for any callable object.</p> <p>If the object is a class, print the constructor information.</p> </dd></dl> <dl class="method"> <dt id="IPython.core.oinspect.Inspector.pdoc"> <tt class="descname">pdoc</tt><big>(</big><em>obj</em>, <em>oname=''</em>, <em>formatter=None</em><big>)</big><a class="headerlink" href="#IPython.core.oinspect.Inspector.pdoc" title="Permalink to this definition">¶</a></dt> <dd><p>Print the docstring for any object.</p> <p>Optional: -formatter: a function to run the docstring through for specially formatted docstrings.</p> <p class="rubric">Examples</p> <dl class="docutils"> <dt>In [1]: class NoInit:</dt> <dd>...: pass</dd> <dt>In [2]: class NoDoc:</dt> <dd>...: def __init__(self): ...: pass</dd> </dl> <p>In [3]: %pdoc NoDoc No documentation found for NoDoc</p> <p>In [4]: %pdoc NoInit No documentation found for NoInit</p> <p>In [5]: obj = NoInit()</p> <p>In [6]: %pdoc obj No documentation found for obj</p> <p>In [5]: obj2 = NoDoc()</p> <p>In [6]: %pdoc obj2 No documentation found for obj2</p> </dd></dl> <dl class="method"> <dt id="IPython.core.oinspect.Inspector.pfile"> <tt class="descname">pfile</tt><big>(</big><em>obj</em>, <em>oname=''</em><big>)</big><a class="headerlink" href="#IPython.core.oinspect.Inspector.pfile" title="Permalink to this definition">¶</a></dt> <dd><p>Show the whole file where an object was defined.</p> </dd></dl> <dl class="method"> <dt id="IPython.core.oinspect.Inspector.pinfo"> <tt class="descname">pinfo</tt><big>(</big><em>obj</em>, <em>oname=''</em>, <em>formatter=None</em>, <em>info=None</em>, <em>detail_level=0</em><big>)</big><a class="headerlink" href="#IPython.core.oinspect.Inspector.pinfo" title="Permalink to this definition">¶</a></dt> <dd><p>Show detailed information about an object.</p> <p>Optional arguments:</p> <ul class="simple"> <li>oname: name of the variable pointing to the object.</li> <li>formatter: special formatter for docstrings (see pdoc)</li> <li>info: a structure with some information fields which may have been precomputed already.</li> <li>detail_level: if set to 1, more information is given.</li> </ul> </dd></dl> <dl class="method"> <dt id="IPython.core.oinspect.Inspector.psearch"> <tt class="descname">psearch</tt><big>(</big><em>pattern</em>, <em>ns_table</em>, <em>ns_search=[]</em>, <em>ignore_case=False</em>, <em>show_all=False</em><big>)</big><a class="headerlink" href="#IPython.core.oinspect.Inspector.psearch" title="Permalink to this definition">¶</a></dt> <dd><p>Search namespaces with wildcards for objects.</p> <p>Arguments:</p> <ul class="simple"> <li>pattern: string containing shell-like wildcards to use in namespace searches and optionally a type specification to narrow the search to objects of that type.</li> <li>ns_table: dict of name->namespaces for search.</li> </ul> <p>Optional arguments:</p> <blockquote> <div><ul class="simple"> <li>ns_search: list of namespace names to include in search.</li> <li>ignore_case(False): make the search case-insensitive.</li> <li>show_all(False): show all names, including those starting with underscores.</li> </ul> </div></blockquote> </dd></dl> <dl class="method"> <dt id="IPython.core.oinspect.Inspector.psource"> <tt class="descname">psource</tt><big>(</big><em>obj</em>, <em>oname=''</em><big>)</big><a class="headerlink" href="#IPython.core.oinspect.Inspector.psource" title="Permalink to this definition">¶</a></dt> <dd><p>Print the source code for an object.</p> </dd></dl> </dd></dl> </div> <div class="section" id="functions"> <h2>10 Functions<a class="headerlink" href="#functions" title="Permalink to this headline">¶</a></h2> <dl class="function"> <dt id="IPython.core.oinspect.object_info"> <tt class="descclassname">IPython.core.oinspect.</tt><tt class="descname">object_info</tt><big>(</big><em>**kw</em><big>)</big><a class="headerlink" href="#IPython.core.oinspect.object_info" title="Permalink to this definition">¶</a></dt> <dd><p>Make an object info dict with all fields present.</p> </dd></dl> <dl class="function"> <dt id="IPython.core.oinspect.get_encoding"> <tt class="descclassname">IPython.core.oinspect.</tt><tt class="descname">get_encoding</tt><big>(</big><em>obj</em><big>)</big><a class="headerlink" href="#IPython.core.oinspect.get_encoding" title="Permalink to this definition">¶</a></dt> <dd><p>Get encoding for python source file defining obj</p> <p>Returns None if obj is not defined in a sourcefile.</p> </dd></dl> <dl class="function"> <dt id="IPython.core.oinspect.getdoc"> <tt class="descclassname">IPython.core.oinspect.</tt><tt class="descname">getdoc</tt><big>(</big><em>obj</em><big>)</big><a class="headerlink" href="#IPython.core.oinspect.getdoc" title="Permalink to this definition">¶</a></dt> <dd><p>Stable wrapper around inspect.getdoc.</p> <p>This can’t crash because of attribute problems.</p> <p>It also attempts to call a getdoc() method on the given object. This allows objects which provide their docstrings via non-standard mechanisms (like Pyro proxies) to still be inspected by ipython’s ? system.</p> </dd></dl> <dl class="function"> <dt id="IPython.core.oinspect.getsource"> <tt class="descclassname">IPython.core.oinspect.</tt><tt class="descname">getsource</tt><big>(</big><em>obj</em>, <em>is_binary=False</em><big>)</big><a class="headerlink" href="#IPython.core.oinspect.getsource" title="Permalink to this definition">¶</a></dt> <dd><p>Wrapper around inspect.getsource.</p> <p>This can be modified by other projects to provide customized source extraction.</p> <p>Inputs:</p> <ul class="simple"> <li>obj: an object whose source code we will attempt to extract.</li> </ul> <p>Optional inputs:</p> <ul class="simple"> <li>is_binary: whether the object is known to come from a binary source. This implementation will skip returning any output for binary objects, but custom extractors may know how to meaningfully process them.</li> </ul> </dd></dl> <dl class="function"> <dt id="IPython.core.oinspect.is_simple_callable"> <tt class="descclassname">IPython.core.oinspect.</tt><tt class="descname">is_simple_callable</tt><big>(</big><em>obj</em><big>)</big><a class="headerlink" href="#IPython.core.oinspect.is_simple_callable" title="Permalink to this definition">¶</a></dt> <dd><p>True if obj is a function ()</p> </dd></dl> <dl class="function"> <dt id="IPython.core.oinspect.getargspec"> <tt class="descclassname">IPython.core.oinspect.</tt><tt class="descname">getargspec</tt><big>(</big><em>obj</em><big>)</big><a class="headerlink" href="#IPython.core.oinspect.getargspec" title="Permalink to this definition">¶</a></dt> <dd><p>Wrapper around <tt class="xref py py-func docutils literal"><span class="pre">inspect.getfullargspec()</span></tt> on Python 3, and :func:inspect.getargspec` on Python 2.</p> <p>In addition to functions and methods, this can also handle objects with a <tt class="docutils literal"><span class="pre">__call__</span></tt> attribute.</p> </dd></dl> <dl class="function"> <dt id="IPython.core.oinspect.format_argspec"> <tt class="descclassname">IPython.core.oinspect.</tt><tt class="descname">format_argspec</tt><big>(</big><em>argspec</em><big>)</big><a class="headerlink" href="#IPython.core.oinspect.format_argspec" title="Permalink to this definition">¶</a></dt> <dd><p>Format argspect, convenience wrapper around inspect’s.</p> <p>This takes a dict instead of ordered arguments and calls inspect.format_argspec with the arguments in the necessary order.</p> </dd></dl> <dl class="function"> <dt id="IPython.core.oinspect.call_tip"> <tt class="descclassname">IPython.core.oinspect.</tt><tt class="descname">call_tip</tt><big>(</big><em>oinfo</em>, <em>format_call=True</em><big>)</big><a class="headerlink" href="#IPython.core.oinspect.call_tip" title="Permalink to this definition">¶</a></dt> <dd><p>Extract call tip data from an oinfo dict.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>oinfo</strong> : dict</p> <p><strong>format_call</strong> : bool, optional</p> <blockquote> <div><p>If True, the call line is formatted and returned as a string. If not, a tuple of (name, argspec) is returned.</p> </div></blockquote> </td> </tr> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>call_info</strong> : None, str or (str, dict) tuple.</p> <blockquote> <div><p>When format_call is True, the whole call information is formattted as a single string. Otherwise, the object’s name and its argspec dict are returned. If no call information is available, None is returned.</p> </div></blockquote> <p><strong>docstring</strong> : str or None</p> <blockquote class="last"> <div><p>The most relevant docstring for calling purposes is returned, if available. The priority is: call docstring for callable instances, then constructor docstring for classes, then main object’s docstring otherwise (regular functions).</p> </div></blockquote> </td> </tr> </tbody> </table> </dd></dl> <dl class="function"> <dt id="IPython.core.oinspect.find_file"> <tt class="descclassname">IPython.core.oinspect.</tt><tt class="descname">find_file</tt><big>(</big><em>obj</em><big>)</big><a class="headerlink" href="#IPython.core.oinspect.find_file" title="Permalink to this definition">¶</a></dt> <dd><p>Find the absolute path to the file where an object was defined.</p> <p>This is essentially a robust wrapper around <cite>inspect.getabsfile</cite>.</p> <p>Returns None if no file can be found.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>obj</strong> : any Python object</p> </td> </tr> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>fname</strong> : str</p> <blockquote class="last"> <div><p>The absolute path to the file where the object was defined.</p> </div></blockquote> </td> </tr> </tbody> </table> </dd></dl> <dl class="function"> <dt id="IPython.core.oinspect.find_source_lines"> <tt class="descclassname">IPython.core.oinspect.</tt><tt class="descname">find_source_lines</tt><big>(</big><em>obj</em><big>)</big><a class="headerlink" href="#IPython.core.oinspect.find_source_lines" title="Permalink to this definition">¶</a></dt> <dd><p>Find the line number in a file where an object was defined.</p> <p>This is essentially a robust wrapper around <cite>inspect.getsourcelines</cite>.</p> <p>Returns None if no file can be found.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>obj</strong> : any Python object</p> </td> </tr> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>lineno</strong> : int</p> <blockquote class="last"> <div><p>The line number where the object definition starts.</p> </div></blockquote> </td> </tr> </tbody> </table> </dd></dl> </div> </div> </div> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="../../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="IPython.core.page.html" title="Module: core.page" >next</a> |</li> <li class="right" > <a href="IPython.core.magics.script.html" title="Module: core.magics.script" >previous</a> |</li> <li><a href="http://ipython.org">home</a>| </li> <li><a href="../../search.html">search</a>| </li> <li><a href="../../index.html">documentation </a> »</li> <li><a href="../index.html" >The IPython API</a> »</li> </ul> </div> <div class="footer"> © Copyright The IPython Development Team. Last updated on Jul 14, 2015. Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.3. </div> </body> </html>