In a cell I have
def function():
stuff
In a cell below the previously mentioned cell, I call
function()
The error I get is:
name 'function' is not defined.
How do I call a function in another cell in iPython?
Run the cell in which you defined the function first, then run the cell you call it from. If you make any changes to the function later, run that cell again for the changes to take effect, otherwise your calls will run the un-changed function.
or, as @ymonad pointed out, run all cells each time. it takes care of the trouble as long as function definition comes before any point it is called upon.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With