IPython notebook is a very nice experimentation platform, however it seems to be a little unintuitive to use when using as part of a larger ‘non-experimental’ codebase. The following shows how a couple of directory tweaks can be made without altering any IPython configuration files.

If there’s a better way to do this, please let me know. This feels like a hack.

### Subdirectory model desired

When coding up a larger project, it’s helpful to have everything in the familiar directory structure :

And standard scripts (for instance src/xyz.py) can be run in {BASE} by simply :

Such scripts can import the internal modules straightforwardly (eg: import Module1), and the base directory for accessing the data will be data/.

At the same time, the IPython notebooks are kept in a separate notebooks/ directory, which is what messes up all the paths.

### IPython notebook preamble

Open up a new IPython notebook in notebooks/, and have the following cell at the start to pull in the modules, and data with the correct relative paths :

Running matplotlib thereafter :

blog comments powered by Disqus