ipython/ipython — pull request #923 by minrk (2011-10-24 09:08:10+00:00)
Title: %config magic

should close #903

Adds %config magic, which allows `%config Foo.bar = 5` configuration of IPython configurables.

The Magic class keeps a list of configurables which will be updated by the change, so any objects that should be accessible to this magic should be appended to `shell.configurables`. I started with everything I saw as configurable in InteractiveShell.

### Usage

Use just `%config` to see what classes are available, and `%config Class` to get the trait info for that class.

When setting values via` %config Class.trait = value` It is evaluated with user_ns in globals, so you can do arbitrary things like:

```python
In [4]: default = 'png'

In [5]: %config InlineBackendConfig.figure_format = raw_input('what figure format should we use? ') or default
```

Of course, this magic reveals just how much we *don't* use traits/config properly. Almost everything is attached to the InteractiveShell object, and has an effect exactly once during an `init_foo()` method, rather than allowing config propagation via `_trait_changed()` methods.

For instance, IPCompleter has an `omit__names` attribute, but the configurable is `InteractiveShell.readline_omit__names`, which is clearly wrong.

We've done a good job with config in *new* code, but I think existing code needs a pretty hefty pass to get configurables attached to the right objects, and getting logic like `%colors` into `shell._colors_changed`.