<div dir="ltr">For the record, I ended up achieving this by modifying KernelManager to invoke the original script in a subprocess (rather than just calling zmq main), and then configuring that binary, when called in kernel mode (i.e. with "kernel" argument), to call IPython.start_kernel with the desired user_ns passed in.<div>

<br></div><div>Is there any documentation for developers who want to better understand the internal IPython APIs, specifically around kernels, applications, etc.? I felt myself digging around somewhat blindly in order to figure this out, and I'm sure there are better ways to do it (that don't require modifying IPython internals).</div>

</div><div class="gmail_extra"><br clear="all"><div><br>--Adam</div>
<br><br><div class="gmail_quote">On Wed, Oct 30, 2013 at 10:32 PM, Adam Sadovsky <span dir="ltr"><<a href="mailto:asadovsky@gmail.com" target="_blank">asadovsky@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr">Hi Paul,<div><br></div><div>Thanks for the reply! The reason I'd like to avoid startup files is that I'm trying to provide a library for others to use. As part of this library, I want it to be possible for people to start a notebook server where any new notebook has a certain set of things pre-imported for convenience. I suppose I could provide a startup file for users to place in their own startup dirs, but I'd like to avoid making users do any extra work. Ideally I'd like an option similar to what's offered in the interactive shell API, which allows users to pass in a user_ns object. Does that make sense?</div>


<div><br></div><div>I should say, I'm relatively new to IPython/notebook and not very familiar with its architecture, so I certainly may be missing something obvious. :)</div></div><div class="gmail_extra"><span class="HOEnZb"><font color="#888888"><br clear="all">


<div><br>--Adam</div></font></span><div><div class="h5">
<br><br><div class="gmail_quote">On Wed, Oct 30, 2013 at 9:11 PM, Paul Ivanov <span dir="ltr"><<a href="mailto:pi@berkeley.edu" target="_blank">pi@berkeley.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div>Adam Sadovsky, on 2013-10-30 20:28,  wrote:<br>
> I recently upgraded from IPython 0.13 to 1.1.<br>
> In 0.13, I was able to execute code in each notebook at startup, but the<br>
> kernel code has changed and I can't figure out how to do it anymore. Could<br>
> someone point me in the right direction?<br>
<br>
</div>Hi Adam,<br>
<br>
why not just use a file in the startup directory?<br>
<br>
$ echo `ipython locate profile`/startup/<br>
/home/pi/.ipython/profile_default/startup/<br>
$ cat `ipython locate profile`/startup/README<br>
This is the IPython startup directory<br>
<br>
.py and .ipy files in this directory will be run *prior* to any<br>
code or files specified<br>
via the exec_lines or exec_files configurables whenever you load<br>
this profile.<br>
<br>
Files will be run in lexicographical order, so you can control<br>
the execution order of files<br>
with a prefix, e.g.::<br>
<br>
  00-first.py<br>
  50-middle.py<br>
  99-last.ipy<br>
<br>
best,<br>
--<br>
                   _<br>
                  / \<br>
                A*   \^   -<br>
             ,./   _.`\\ / \<br>
            / ,--.S    \/   \<br>
           /  `"~,_     \    \<br>
     __o           ?<br>
   _ \<,_         /:\<br>
--(_)/-(_)----.../ | \<br>
--------------.......J<br>
<span><font color="#888888">Paul Ivanov<br>
<a href="http://pirsquared.org" target="_blank">http://pirsquared.org</a><br>
_______________________________________________<br>
IPython-dev mailing list<br>
<a href="mailto:IPython-dev@scipy.org" target="_blank">IPython-dev@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
</font></span></blockquote></div><br></div></div></div>
</blockquote></div><br></div>