r/IPython • u/masterkuch • Apr 11 '18
Jupyter background data storage is confusing
For example:
from abc import xyz as 123 # creates alias 123 for xyz
Then I delete the code above, replace it with the code below and rerun the cell.
from abc import xyz
Nonetheless, alias 123 remains functional as it stored in memory and is only erased if you restart the kernel.
This leads to confusion (or forces you to keep track of more things) when you run the code after making edits - some errors are not raised because their dependencies (such as 123) are stored an remain accessible.
Also, all variables (even those defined within a function) are global.
My intuition is that these differences (from normal ide coding environment) will result in confusion and I want to turn of this feature; however, it might be the case that I am misusing Jupyter and these features are in fact advantageous. If so, can you please educate me?
Thank you very much
Edit: formating
View all comments
Show parent comment
1
u/masterkuch Apr 16 '18 edited Apr 16 '18
Hey, I wanted to thank you again for elucidating the problem. I now understand why (and how) Jupyter behaves the way it does.
This was false; I misinterpreted 'stateful behavior' for global variables (justifiably so?).
Is the google forum the platform used for discussions as such?
It seems like dfkernel is more flexible than nodebook, that is, code cells maintain their order of execution (akin to a linked list) in spite of actual cell order. The advantage is that the code cell can be placed around explanatory cells. In nodebook, the cells have to be run in order and explanatory cells have to accommodate this order. The disadvatage is in the way dfkernel alters the code, that is, now you have to code for cells dependencies,
... and this deviates from normal python code (every other user who will be using my notebooks will have to install dfkernel).
I think for nodebook is a good starting point for noobs like myself and dfkernel ought to be used in serious scientific notebooks. What do you think? Cheers!