OInspect — IPython v0.10 documentation

### Navigation

- index
- modules |
- next |
- previous |
- IPython v0.10 documentation »
- The IPython API »

# OInspect

## Module: `OInspect`

Inheritance diagram for `IPython.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.

## Classes

### `Inspector`

class `IPython.OInspect.` `Inspector`(color_table, code_color_table, scheme, str_detail_level=0)
  `__init__`(color_table, code_color_table, scheme, str_detail_level=0)
  `noinfo`(msg, oname)
    Generic message when no information is found.
  `pdef`(obj, oname='')

    Print the definition header 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.

  `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.
  `set_active_scheme`(scheme)

### `myStringIO`

class `IPython.OInspect.` `myStringIO`(buf='')

  Bases: `StringIO.StringIO`

  Adds a writeln method to normal StringIO.

  `__init__`(buf='')
  `writeln`(*arg, **kw)
    Does a write() and then a write(‘ ‘)

## Functions

`IPython.OInspect.` `getargspec`(obj)

  Get the names and default values of a function’s arguments.

  A tuple of four things is returned: (args, varargs, varkw, defaults). ‘args’ is a list of the argument names (it may contain nested lists). ‘varargs’ and ‘varkw’ are the names of the * and ** arguments or None. ‘defaults’ is an n-tuple of the default values of the last n arguments.

  Modified version of inspect.getargspec from the Python Standard Library.

`IPython.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.OInspect.` `getsource`(obj, is_binary=False)

  Wrapper around inspect.getsource.

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

  Inputs:

  - obj: an object whose source code we will attempt to extract.

  Optional inputs:

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

### Navigation

- index
- modules |
- next |
- previous |
- IPython v0.10 documentation »
- The IPython API »