helloidea
helloidea

Reputation: 13

Which method of IPython is the Jupyter Notebook executing the Python code in the cell?

Looking at the source code for the Jupyter Notebook on GitHub, it looks like I'm using IPython to implement the Python interpreter.

I would like to know where in which file the Python code is executed in the source code of Jupyter Notebook.

(Jupyter Notebook seems to send Python code to the server via websocket. That's about it now.)

Upvotes: 0

Views: 150

Answers (1)

Matt
Matt

Reputation: 27843

As a warning, you really do not want to look at how IPython is doing things if you are trying to understand how Python code is executing. We do extremely complex things to suport weird features, like top-level async execution.

As you pointed out in your comments, the flow of code is Browser -> Server (via Websocket) -> IPykernel (via ZMQ) -> IPython.

IPython itself will do a bunch of transforms, and the code compile/exec will be here

What you are likely looking for is the compile and exec, and well as cmd module to write a REPL. I would also strongly recommend looking at prompt toolkit as a cmd replacement.

Upvotes: 1

Related Questions