IPython Documentation

Table Of Contents

Previous topic

core.pylabtools

Next topic

core.splitinput

This Page

core.shellapp

Module: core.shellapp

Inheritance diagram for IPython.core.shellapp:

A mixin for Application classes that launch InteractiveShell instances, load extensions, etc.

Authors

  • Min Ragan-Kelley

InteractiveShellApp

class IPython.core.shellapp.InteractiveShellApp(**kwargs)

Bases: IPython.config.configurable.Configurable

A Mixin for applications that start InteractiveShell instances.

Provides configurables for loading extensions and executing files as part of configuring a Shell environment.

The following methods should be called by the initialize() method of the subclass:

__init__(**kwargs)

Create a configurable given a config config.

Parameters :

config : Config

If this is empty, default values are used. If config is a Config instance, it will be used to configure the instance.

Notes

Subclasses of Configurable must call the __init__() method of Configurable before doing anything else and using super():

class MyConfigurable(Configurable):
    def __init__(self, config=None):
        super(MyConfigurable, self).__init__(config)
        # Then any other code you need to finish initialization.

This ensures that instances will be configured properly.

classmethod class_config_section()

Get the config class config section

classmethod class_get_help(inst=None)

Get the help string for this class in ReST format.

If inst is given, it’s current trait values will be used in place of class defaults.

classmethod class_get_trait_help(trait, inst=None)

Get the help string for a single trait.

If inst is given, it’s current trait values will be used in place of the class default.

classmethod class_print_help(inst=None)

Get the help string for a single trait and print it.

classmethod class_trait_names(**metadata)

Get a list of all the names of this classes traits.

This method is just like the trait_names() method, but is unbound.

classmethod class_traits(**metadata)

Get a list of all the traits of this class.

This method is just like the traits() method, but is unbound.

The TraitTypes returned don’t know anything about the values that the various HasTrait’s instances are holding.

This follows the same algorithm as traits does and does not allow for any simple way of specifying merely that a metadata name exists, but has any value. This is because get_metadata returns None if a metadata key doesn’t exist.

code_to_run

A trait for unicode strings.

config

A trait whose value must be an instance of a specified class.

The value can also be an instance of a subclass of the specified class.

created = None
default_extensions

An instance of a Python list.

exec_files

An instance of a Python list.

exec_lines

An instance of a Python list.

extensions

An instance of a Python list.

extra_extension

A trait for unicode strings.

file_to_run

A trait for unicode strings.

gui

An enum of strings that are caseless in validate.

init_code()

run the pre-flight code, specified via exec_lines

init_extensions()

Load all IPython extensions in IPythonApp.extensions.

This uses the ExtensionManager.load_extensions() to load all the extensions listed in self.extensions.

init_gui_pylab()

Enable GUI event loop integration, taking pylab into account.

init_path()

Add current working directory, ‘’, to sys.path

init_shell()
module_to_run

A trait for unicode strings.

on_trait_change(handler, name=None, remove=False)

Setup a handler to be called when a trait changes.

This is used to setup dynamic notifications of trait changes.

Static handlers can be created by creating methods on a HasTraits subclass with the naming convention ‘_[traitname]_changed’. Thus, to create static handler for the trait ‘a’, create the method _a_changed(self, name, old, new) (fewer arguments can be used, see below).

Parameters :

handler : callable

A callable that is called when a trait changes. Its signature can be handler(), handler(name), handler(name, new) or handler(name, old, new).

name : list, str, None

If None, the handler will apply to all traits. If a list of str, handler will apply to all names in the list. If a str, the handler will apply just to that name.

remove : bool

If False (the default), then install the handler. If True then unintall it.

pylab

An enum of strings that are caseless in validate.

pylab_import_all

A boolean (True, False) trait.

shell

A trait whose value must be an instance of a specified class.

The value can also be an instance of a subclass of the specified class.

trait_metadata(traitname, key)

Get metadata values for trait by key.

trait_names(**metadata)

Get a list of all the names of this classes traits.

traits(**metadata)

Get a list of all the traits of this class.

The TraitTypes returned don’t know anything about the values that the various HasTrait’s instances are holding.

This follows the same algorithm as traits does and does not allow for any simple way of specifying merely that a metadata name exists, but has any value. This is because get_metadata returns None if a metadata key doesn’t exist.

update_config(config)

Fire the traits events when the config is updated.