stencila / py

Stencila for Python
Apache License 2.0
17 stars 1 forks source link

Python can't see the loaded libraries? #22

Closed apawlik closed 6 years ago

apawlik commented 6 years ago

image

nokome commented 6 years ago

This was not so much a bug as an artifact of our current execution model which executes a cell's code locally without affecting the execution context's variable namespace. So pd is a local variable in the first cell that is not available in the second. That's a more functional treatment of cells but causes confusion due to the difference with other notebooks and the console.

So what I have done is to treat import statements like variable assignments and function definitions so that they create a named cell output. This is the 'correct' way forward because it allows for reactive imports. See example below.

Based on user testing we've talked about the need to allow for multiple named outputs per cell. That would make your example valid. However, it requires changes to the engine. So you will need to have one import per cell at the moment.

peek 2018-08-03 15-26