### Navigation

- index
- modules |
- next |
- previous |
- home|
- search|
- documentation »
- The IPython API »

# Module: `core.oinspect`

Tools for inspecting Python objects.

Uses syntax highlighting for presenting the various information elements.

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.

## 1 Class

class `IPython.core.oinspect.``Inspector`(color_table={'': <IPython.utils.coloransi.ColorScheme instance at 0x5ace5d40>, 'LightBG': <IPython.utils.coloransi.ColorScheme instance at 0x5ace5d88>, 'NoColor': <IPython.utils.coloransi.ColorScheme instance at 0x5acdec20>, 'Linux': <IPython.utils.coloransi.ColorScheme instance at 0x5ace5d40>}, code_color_table={'': <IPython.utils.coloransi.ColorScheme instance at 0x491c9b48>, u'LightBG': <IPython.utils.coloransi.ColorScheme instance at 0x491c9b90>, u'NoColor': <IPython.utils.coloransi.ColorScheme instance at 0x491c9638>, u'Linux': <IPython.utils.coloransi.ColorScheme instance at 0x491c9b48>}, scheme='NoColor', str_detail_level=0)
  `__init__`(color_table={'': <IPython.utils.coloransi.ColorScheme instance at 0x5ace5d40>, 'LightBG': <IPython.utils.coloransi.ColorScheme instance at 0x5ace5d88>, 'NoColor': <IPython.utils.coloransi.ColorScheme instance at 0x5acdec20>, 'Linux': <IPython.utils.coloransi.ColorScheme instance at 0x5ace5d40>}, code_color_table={'': <IPython.utils.coloransi.ColorScheme instance at 0x491c9b48>, u'LightBG': <IPython.utils.coloransi.ColorScheme instance at 0x491c9b90>, u'NoColor': <IPython.utils.coloransi.ColorScheme instance at 0x491c9638>, u'Linux': <IPython.utils.coloransi.ColorScheme instance at 0x491c9b48>}, scheme='NoColor', str_detail_level=0)
  `info`(obj, oname='', formatter=None, info=None, detail_level=0)

    Compute a dict with detailed information about an object.

    Optional arguments:

    - oname: name of the variable pointing to the object.
    - formatter: special formatter for docstrings (see pdoc)
    - info: a structure with some information fields which may have been precomputed already.
    - detail_level: if set to 1, more information is given.
  `noinfo`(msg, oname)

    Generic message when no information is found.

  `pdef`(obj, oname='')

    Print the call signature for any callable object.

    If the object is a class, print the constructor information.

  `pdoc`(obj, oname='', formatter=None)

    Print the docstring for any object.

    Optional: -formatter: a function to run the docstring through for specially formatted docstrings.

    Examples

    In [1]: class NoInit:
      ...: pass
    In [2]: class NoDoc:
      ...: def __init__(self): ...: pass

    In [3]: %pdoc NoDoc No documentation found for NoDoc

    In [4]: %pdoc NoInit No documentation found for NoInit

    In [5]: obj = NoInit()

    In [6]: %pdoc obj No documentation found for obj

    In [5]: obj2 = NoDoc()

    In [6]: %pdoc obj2 No documentation found for obj2

  `pfile`(obj, oname='')

    Show the whole file where an object was defined.

  `pinfo`(obj, oname='', formatter=None, info=None, detail_level=0)

    Show detailed information about an object.

    Optional arguments:

    - oname: name of the variable pointing to the object.
    - formatter: special formatter for docstrings (see pdoc)
    - info: a structure with some information fields which may have been precomputed already.
    - detail_level: if set to 1, more information is given.
  `psearch`(pattern, ns_table, ns_search=[], ignore_case=False, show_all=False)

    Search namespaces with wildcards for objects.

    Arguments:

    - 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.
    - ns_table: dict of name->namespaces for search.

    Optional arguments:

    > - ns_search: list of namespace names to include in search.
    > - ignore_case(False): make the search case-insensitive.
    > - show_all(False): show all names, including those starting with underscores.

  `psource`(obj, oname='')

    Print the source code for an object.

## 10 Functions

`IPython.core.oinspect.``object_info`(**kw)

  Make an object info dict with all fields present.

`IPython.core.oinspect.``get_encoding`(obj)

  Get encoding for python source file defining obj

  Returns None if obj is not defined in a sourcefile.

`IPython.core.oinspect.``getdoc`(obj)

  Stable wrapper around inspect.getdoc.

  This can’t crash because of attribute problems.

  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.

`IPython.core.oinspect.``getsource`(obj, oname='')

  Wrapper around inspect.getsource.

  This can be modified by other projects to provide customized source extraction.

  Parameters:

  obj : object

  > an object whose source code we will attempt to extract

  oname : str

  > (optional) a name under which the object is known

  Returns: | src : unicode or None

`IPython.core.oinspect.``is_simple_callable`(obj)

  True if obj is a function ()

`IPython.core.oinspect.``getargspec`(obj)

  Wrapper around `inspect.getfullargspec()` on Python 3, and :func:inspect.getargspec` on Python 2.

  In addition to functions and methods, this can also handle objects with a `__call__` attribute.

`IPython.core.oinspect.``format_argspec`(argspec)

  Format argspect, convenience wrapper around inspect’s.

  This takes a dict instead of ordered arguments and calls inspect.format_argspec with the arguments in the necessary order.

`IPython.core.oinspect.``call_tip`(oinfo, format_call=True)

  Extract call tip data from an oinfo dict.

  Parameters:

  oinfo : dict

  format_call : bool, optional

  > If True, the call line is formatted and returned as a string. If not, a tuple of (name, argspec) is returned.

  Returns:

  call_info : None, str or (str, dict) tuple.

  > 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.

  docstring : str or None

  > 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).

`IPython.core.oinspect.``find_file`(obj)

  Find the absolute path to the file where an object was defined.

  This is essentially a robust wrapper around `inspect.getabsfile`.

  Returns None if no file can be found.

  Parameters: | obj : any Python object

  Returns:

  fname : str

  > The absolute path to the file where the object was defined.

`IPython.core.oinspect.``find_source_lines`(obj)

  Find the line number in a file where an object was defined.

  This is essentially a robust wrapper around `inspect.getsourcelines`.

  Returns None if no file can be found.

  Parameters: | obj : any Python object

  Returns:

  lineno : int

  > The line number where the object definition starts.

### Navigation

- index
- modules |
- next |
- previous |
- home|
- search|
- documentation »
- The IPython API »