[IPython-dev] question about command line options

Kyle Rawlins rawlins at gmail.com
Wed Mar 11 16:48:23 EDT 2015

I’ve been trying to update some of my stuff for ipython 3, and hitting basic roadblock to do with passing configuration options.  I have some code that starts the notebook programmatically, and passes an exec_lines option to IPKernelApp.  Something to do with the parsing, or not parsing of quote marks is completely messing me up, and I can’t figure it out.  Right now, it looks like IPKernelApp is guessing where there should be quote marks, and doesn’t always get it right.  But setting that aside for the moment, here’s a tip-of-the-iceberg MWE that illustrates some of the weirdness at the command line, maybe someone can give me a pointer to where in the code this is happening.

The command (at the command line, OS X, so the outer single quotes are interpreted by the shell)
	ipython3 --InteractiveShellApp.exec_lines='["print(2)"]’ 
works, whereas 
	ipython3 notebook --IPKernelApp.exec_lines='["print(2)”]'
 does not (just silently doesn't print a 2). This, as far as I can tell, did work in IPython 2.

In contrast, the command:
	ipython3 --InteractiveShellApp.exec_lines='[print(2)]’
does not work (fails with an error), but 
	ipython3 notebook --IPKernelApp.exec_lines='[print(2)]’
does work!

The problem seems to come with whatever magic is (successfully?) guessing that the thing inside the bracket should be quoted for IPKernelApp only.  With my actual exec_lines command it appears to not get this right, resulting in the silent behavior shown in the first case, but I haven’t even begun to figure out where to look to debug this, and it seemed easier to start with this simpler example.  Any ideas?


Kyle Rawlins
Department of Cognitive Science
Johns Hopkins University

More information about the IPython-dev mailing list